Submission #992450
Source Code Expand
#include <bits/stdc++.h> using namespace std; int N, M; int A[100000]; vector<int> B[100000]; int special(int x) { int y=B[x].size(); return y/2; } int paircount(int x) { map<int, int> m; for(int i=0; i<(int)B[x].size(); i++) m[B[x][i]]++; int ret=0; for(auto& it: m) ret+=it.second/2; return ret; } int main() { scanf("%d%d", &N, &M); for(int i=0; i<N; i++) { scanf("%d", A+i); B[A[i]%M].push_back(A[i]); } int ans=special(0); if(M%2==0) ans+=special(M/2); for(int i=1; i<M-i; i++) { int x=i; int y=M-i; sort(B[x].begin(), B[x].end()); sort(B[y].begin(), B[y].end()); if(B[x].size()<B[y].size()) B[x].swap(B[y]); int px=paircount(x); int py=paircount(y); int sx=B[x].size(); int sy=B[y].size(); while(sx>sy && px--) ans++, sx-=2; ans+=min(sx, sy); } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | FatalEagle |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1068 Byte |
Status | AC |
Exec Time | 33 ms |
Memory | 6144 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &N, &M); ^ ./Main.cpp:31:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", A+i); ^
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 5 ms | 2560 KB |
01-02.txt | AC | 16 ms | 3452 KB |
01-03.txt | AC | 16 ms | 3580 KB |
01-04.txt | AC | 29 ms | 4472 KB |
01-05.txt | AC | 25 ms | 4224 KB |
01-06.txt | AC | 27 ms | 3712 KB |
01-07.txt | AC | 26 ms | 3456 KB |
01-08.txt | AC | 25 ms | 3584 KB |
01-09.txt | AC | 25 ms | 3584 KB |
01-10.txt | AC | 29 ms | 4224 KB |
01-11.txt | AC | 30 ms | 4992 KB |
01-12.txt | AC | 18 ms | 3452 KB |
01-13.txt | AC | 18 ms | 3452 KB |
01-14.txt | AC | 16 ms | 3472 KB |
01-15.txt | AC | 31 ms | 4352 KB |
01-16.txt | AC | 28 ms | 3712 KB |
01-17.txt | AC | 26 ms | 3456 KB |
01-18.txt | AC | 27 ms | 3840 KB |
01-19.txt | AC | 28 ms | 3712 KB |
01-20.txt | AC | 33 ms | 6144 KB |
01-21.txt | AC | 17 ms | 3520 KB |
01-22.txt | AC | 21 ms | 3456 KB |
01-23.txt | AC | 21 ms | 3584 KB |
01-24.txt | AC | 20 ms | 3584 KB |
01-25.txt | AC | 22 ms | 3712 KB |
01-26.txt | AC | 22 ms | 3712 KB |
01-27.txt | AC | 18 ms | 4352 KB |
01-28.txt | AC | 7 ms | 2688 KB |
01-29.txt | AC | 6 ms | 2560 KB |
01-30.txt | AC | 6 ms | 2560 KB |
sample-01.txt | AC | 5 ms | 2560 KB |
sample-02.txt | AC | 5 ms | 2560 KB |