Submission #7458491


Source Code Expand

Copy
#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 Info

Submission Time
Task D - Pair Cards
User hana
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1036 Byte
Status
Exec Time 70 ms
Memory 7296 KB

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 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
Case Name Status Exec Time Memory
01-01.txt 1 ms 256 KB
01-02.txt 61 ms 4224 KB
01-03.txt 61 ms 4224 KB
01-04.txt 61 ms 4224 KB
01-05.txt 62 ms 4224 KB
01-06.txt 61 ms 4224 KB
01-07.txt 61 ms 4224 KB
01-08.txt 61 ms 4224 KB
01-09.txt 61 ms 4224 KB
01-10.txt 62 ms 4864 KB
01-11.txt 63 ms 5760 KB
01-12.txt 30 ms 256 KB
01-13.txt 30 ms 256 KB
01-14.txt 68 ms 6528 KB
01-15.txt 69 ms 6528 KB
01-16.txt 69 ms 6528 KB
01-17.txt 69 ms 6528 KB
01-18.txt 69 ms 6528 KB
01-19.txt 70 ms 6656 KB
01-20.txt 70 ms 7296 KB
01-21.txt 39 ms 512 KB
01-22.txt 39 ms 512 KB
01-23.txt 39 ms 512 KB
01-24.txt 39 ms 512 KB
01-25.txt 40 ms 1024 KB
01-26.txt 47 ms 2048 KB
01-27.txt 34 ms 3712 KB
01-28.txt 3 ms 1408 KB
01-29.txt 2 ms 640 KB
01-30.txt 1 ms 256 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB