Submission #993113
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb push_back #define INF (1e9+1) //#define INF (1LL<<59) int f(int p,int n){ if(n%2!=0)n--; return min(n,p*2)/2; } int main(){ int n,m; cin>>n>>m; vector<int> num(m,0); vector<int> sm(m,0); map<int,int> mp; rep(i,n){ int x; cin>>x; num[ x%m ]++; mp[x]++; } for(auto &e:mp){ sm[e.first%m]+=e.second/2; } // rep(i,m)cout<<num[i]<<" ";cout<<endl; // rep(i,m)cout<<sm [i]<<" ";cout<<endl; ll ans=0; ans+=num[0]/2; num[0]-=num[0]; int c=0; while(1){ if(c==m-c){ ans+=num[c]/2; num[c]-=num[c]; break; } if(c>m-c)break; ans+=min(num[c],num[m-c]); num[c] -= min(num[c],num[m-c]); num[m-c] -= min(num[c],num[m-c]); c++; } rep(i,m){ if(sm[i]!=0){ ans+=f(sm[i],num[i]); } } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | Yazaten |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1235 Byte |
Status | WA |
Exec Time | 72 ms |
Memory | 5760 KB |
Judge Result
Set Name | sample | all | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
all | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 3 ms | 256 KB |
01-02.txt | AC | 60 ms | 3200 KB |
01-03.txt | AC | 61 ms | 3200 KB |
01-04.txt | WA | 61 ms | 3200 KB |
01-05.txt | WA | 60 ms | 3200 KB |
01-06.txt | WA | 60 ms | 3200 KB |
01-07.txt | WA | 60 ms | 3200 KB |
01-08.txt | WA | 60 ms | 3200 KB |
01-09.txt | WA | 60 ms | 3200 KB |
01-10.txt | WA | 61 ms | 3584 KB |
01-11.txt | WA | 62 ms | 3968 KB |
01-12.txt | AC | 31 ms | 256 KB |
01-13.txt | AC | 31 ms | 640 KB |
01-14.txt | AC | 68 ms | 4992 KB |
01-15.txt | AC | 68 ms | 4992 KB |
01-16.txt | AC | 68 ms | 4992 KB |
01-17.txt | AC | 71 ms | 4992 KB |
01-18.txt | AC | 68 ms | 4992 KB |
01-19.txt | AC | 72 ms | 4992 KB |
01-20.txt | AC | 69 ms | 5760 KB |
01-21.txt | AC | 39 ms | 384 KB |
01-22.txt | WA | 39 ms | 384 KB |
01-23.txt | WA | 39 ms | 384 KB |
01-24.txt | WA | 39 ms | 384 KB |
01-25.txt | WA | 44 ms | 640 KB |
01-26.txt | WA | 41 ms | 1152 KB |
01-27.txt | AC | 34 ms | 3328 KB |
01-28.txt | WA | 5 ms | 1152 KB |
01-29.txt | AC | 3 ms | 640 KB |
01-30.txt | AC | 4 ms | 1024 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 3 ms | 256 KB |