Submission #5874479
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) signed main(){ int n,m;cin>>n>>m; vector<int>x(n); for(auto&& u:x)cin>>u; map<int,int>cnt,cntp,cntm; for(auto&& u:x){cnt[u]++;cntm[u%m]++;} for(auto&& u:cnt){cntp[u.first%m]+=u.second/2;} int ret=0; ret+=cntm[0]/2; if(m%2==0)ret+=cntm[m/2]/2; for(int i=1;i<=(m-1)/2;i++){ int x=i,y=m-x; if(cntm[x]>cntm[y])swap(x,y); int nx=cntm[x],ny=cntm[y]; ret+=nx; ret+=min((ny-nx)/2,cntp[y]); } cout<<ret<<endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | mnrutd |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 562 Byte |
Status | AC |
Exec Time | 182 ms |
Memory | 19840 KB |
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 58 ms | 4992 KB |
01-03.txt | AC | 60 ms | 4992 KB |
01-04.txt | AC | 60 ms | 4992 KB |
01-05.txt | AC | 61 ms | 4992 KB |
01-06.txt | AC | 62 ms | 4992 KB |
01-07.txt | AC | 63 ms | 4992 KB |
01-08.txt | AC | 69 ms | 4992 KB |
01-09.txt | AC | 75 ms | 5248 KB |
01-10.txt | AC | 105 ms | 9728 KB |
01-11.txt | AC | 130 ms | 15616 KB |
01-12.txt | AC | 30 ms | 1024 KB |
01-13.txt | AC | 47 ms | 5120 KB |
01-14.txt | AC | 67 ms | 7296 KB |
01-15.txt | AC | 68 ms | 7296 KB |
01-16.txt | AC | 72 ms | 7296 KB |
01-17.txt | AC | 78 ms | 7296 KB |
01-18.txt | AC | 86 ms | 7680 KB |
01-19.txt | AC | 97 ms | 8832 KB |
01-20.txt | AC | 182 ms | 19840 KB |
01-21.txt | AC | 38 ms | 1280 KB |
01-22.txt | AC | 39 ms | 1280 KB |
01-23.txt | AC | 41 ms | 1280 KB |
01-24.txt | AC | 46 ms | 1408 KB |
01-25.txt | AC | 60 ms | 4096 KB |
01-26.txt | AC | 84 ms | 10624 KB |
01-27.txt | AC | 94 ms | 13184 KB |
01-28.txt | AC | 38 ms | 9856 KB |
01-29.txt | AC | 13 ms | 3968 KB |
01-30.txt | AC | 47 ms | 9600 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |