Submission #992055
Source Code Expand
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using D = double; using uint = unsigned int; #ifdef WIN32 #define LLD "%I64d" #else #define LLD "%lld" #endif #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second map<int, int> kv; vector<int> cnt[100005]; int n, m; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { int x; scanf("%d", &x); kv[x]++; } for (auto t : kv) if (t.se % 2 == 1) { cnt[t.fi % m].pb(t.fi); } for (auto t : kv) { for (int i = 0; i < t.se - t.se % 2; i++) cnt[t.fi % m].pb(t.fi); } int answer = 0; for (int i = 0; i * 2 <= m; i++) { if (i + i == m || i == 0) { int k = cnt[i].size() / 2; for (auto t = 0; t < 2 * k; t++) kv[cnt[i][t]]--; answer += k; } else { int k = min(cnt[i].size(), cnt[m - i].size()); for (auto t = 0; t < k; t++) kv[cnt[i][t]]--; for (auto t = 0; t < k; t++) kv[cnt[m - i][t]]--; answer += k; } } for (auto t : kv) { answer += t.se / 2; } printf("%d\n", answer); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | KAN |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1373 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 10368 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:32:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &x); ^
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 | 55 ms | 6144 KB |
01-03.txt | AC | 57 ms | 6080 KB |
01-04.txt | AC | 58 ms | 6144 KB |
01-05.txt | AC | 59 ms | 6144 KB |
01-06.txt | AC | 61 ms | 6272 KB |
01-07.txt | AC | 63 ms | 6016 KB |
01-08.txt | AC | 63 ms | 6144 KB |
01-09.txt | AC | 62 ms | 6144 KB |
01-10.txt | AC | 60 ms | 6784 KB |
01-11.txt | AC | 59 ms | 7552 KB |
01-12.txt | AC | 16 ms | 3196 KB |
01-13.txt | AC | 16 ms | 3196 KB |
01-14.txt | AC | 67 ms | 7932 KB |
01-15.txt | AC | 75 ms | 7936 KB |
01-16.txt | AC | 78 ms | 7936 KB |
01-17.txt | AC | 80 ms | 7808 KB |
01-18.txt | AC | 76 ms | 8064 KB |
01-19.txt | AC | 72 ms | 7936 KB |
01-20.txt | AC | 72 ms | 10368 KB |
01-21.txt | AC | 26 ms | 3232 KB |
01-22.txt | AC | 26 ms | 3328 KB |
01-23.txt | AC | 26 ms | 3328 KB |
01-24.txt | AC | 27 ms | 3328 KB |
01-25.txt | AC | 26 ms | 3456 KB |
01-26.txt | AC | 25 ms | 3456 KB |
01-27.txt | AC | 33 ms | 6656 KB |
01-28.txt | AC | 7 ms | 2816 KB |
01-29.txt | AC | 5 ms | 2688 KB |
01-30.txt | AC | 5 ms | 2560 KB |
sample-01.txt | AC | 5 ms | 2560 KB |
sample-02.txt | AC | 5 ms | 2560 KB |