Submission #993106
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; #define MAX_N 100005 int N; LL M; LL X[MAX_N]; int MAP[MAX_N], MAP2[MAX_N]; set<int> SET; void input() { cin >> N >> M; for (size_t i = 0; i < N; i++) { scanf("%lld", &X[i]); } } int main() { input(); for (size_t i = 0; i < N; i++) { MAP[X[i]%M]++; if(!SET.insert(X[i]).second){ MAP2[X[i]%M]++; SET.erase(X[i]); } } LL ans = 0; for (int i = 1; i < (M+1)/2; i++) { LL tmp = min(MAP[i], MAP[M-i]); LL tmp2; LL L = (MAP[i] - MAP2[i]*2); if(tmp >= L) tmp2 = (MAP2[i]*2 - (tmp - L))/2; else tmp2 = MAP2[i]; LL tmp3; L = (MAP[M-i] - MAP2[M-i]*2); if(tmp >= L) tmp3 = (MAP2[M-i]*2 - (tmp - L))/2; else tmp3 = MAP2[M-i]; ans += tmp + tmp2 + tmp3; //cerr << tmp << " " << tmp2 << " " << tmp3 << endl; } ans += MAP[0]/2; if(M%2 == 0){ ans += MAP[M/2]/2; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | takoshi |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1044 Byte |
Status | AC |
Exec Time | 46 ms |
Memory | 6144 KB |
Compile Error
./Main.cpp: In function ‘void input()’: ./Main.cpp:19:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &X[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 | 3 ms | 256 KB |
01-02.txt | AC | 42 ms | 3072 KB |
01-03.txt | AC | 42 ms | 3072 KB |
01-04.txt | AC | 42 ms | 3072 KB |
01-05.txt | AC | 42 ms | 3072 KB |
01-06.txt | AC | 42 ms | 3200 KB |
01-07.txt | AC | 42 ms | 3072 KB |
01-08.txt | AC | 43 ms | 3072 KB |
01-09.txt | AC | 42 ms | 3072 KB |
01-10.txt | AC | 43 ms | 3328 KB |
01-11.txt | AC | 44 ms | 3840 KB |
01-12.txt | AC | 16 ms | 1024 KB |
01-13.txt | AC | 16 ms | 1024 KB |
01-14.txt | AC | 45 ms | 5760 KB |
01-15.txt | AC | 45 ms | 5760 KB |
01-16.txt | AC | 45 ms | 5760 KB |
01-17.txt | AC | 45 ms | 5760 KB |
01-18.txt | AC | 45 ms | 5760 KB |
01-19.txt | AC | 45 ms | 5760 KB |
01-20.txt | AC | 46 ms | 6144 KB |
01-21.txt | AC | 29 ms | 1152 KB |
01-22.txt | AC | 29 ms | 1152 KB |
01-23.txt | AC | 29 ms | 1152 KB |
01-24.txt | AC | 29 ms | 1152 KB |
01-25.txt | AC | 29 ms | 1408 KB |
01-26.txt | AC | 30 ms | 1920 KB |
01-27.txt | AC | 23 ms | 3200 KB |
01-28.txt | AC | 4 ms | 1024 KB |
01-29.txt | AC | 3 ms | 384 KB |
01-30.txt | AC | 3 ms | 256 KB |
sample-01.txt | AC | 3 ms | 256 KB |
sample-02.txt | AC | 3 ms | 256 KB |