CODE FESTIVAL 2016 Final

Submission #7458491

Source codeソースコード

#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll N,M;
ll modMap[100010];
ll modPairMap[100010];

int main(){
    cin>>N>>M;    
    map<ll,ll> mp;
    for(ll i=0;i<N;i++){
        ll x;
        cin>>x;
        modMap[x%M]++;
        mp[x]++;
    }
    for(auto p:mp){
        if(p.second>1){
            modPairMap[p.first%M]+=p.second;
        }
    }
    // for(ll i=0;i<M;i++){
    //     cout<<i<<":"<<modMap[i]<<endl;
    // }
    ll ans=modMap[0]/2;
    for(ll i=1;i<(M+1)/2;i++){
        ans+=min(modMap[i],modMap[M-i]);
        if(modMap[i]>modMap[M-i]){
            ans+=min(modPairMap[i],modMap[i]-modMap[M-i])/2;
        }else{
            ans+=min(modPairMap[M-1-i],modMap[M-i]-modMap[i])/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 hana
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1036 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 700 sample-01.txt,sample-02.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt,01-11.txt,01-12.txt,01-13.txt,01-14.txt,01-15.txt,01-16.txt,01-17.txt,01-18.txt,01-19.txt,01-20.txt,01-21.txt,01-22.txt,01-23.txt,01-24.txt,01-25.txt,01-26.txt,01-27.txt,01-28.txt,01-29.txt,01-30.txt,sample-01.txt,sample-02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 1 ms 256 KB
01-02.txt AC 61 ms 4224 KB
01-03.txt WA
01-04.txt AC 61 ms 4224 KB
01-05.txt WA
01-06.txt AC 61 ms 4224 KB
01-07.txt WA
01-08.txt AC 61 ms 4224 KB
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt AC 30 ms 256 KB
01-13.txt AC 30 ms 256 KB
01-14.txt WA
01-15.txt AC 69 ms 6528 KB
01-16.txt WA
01-17.txt AC 69 ms 6528 KB
01-18.txt AC 69 ms 6528 KB
01-19.txt AC 70 ms 6656 KB
01-20.txt AC 70 ms 7296 KB
01-21.txt WA
01-22.txt AC 39 ms 512 KB
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt AC 34 ms 3712 KB
01-28.txt WA
01-29.txt AC 2 ms 640 KB
01-30.txt AC 1 ms 256 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB