Submission #6364145
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 100 * 1000 + 17; const int MOD = 1000 * 1000 * 1000 + 7; int n, m; int a[N]; bool read() { if (!(cin >> n >> m)) return false; for (int i = 0; i < n; ++i) cin >> a[i]; return true; } void solve() { auto ans = 0; map<int, int> f, g, h; for (int i = 0; i < n; ++i) if (a[i] % m == 0) ++ans; else ++f[a[i]]; ans /= 2; for (auto p : f) { ans += p.second / 2; if (p.second >= 2) h[p.first % m] += p.second / 2; if (p.second & 1) ++g[p.first % m]; } vector<int> keys; for (auto p : g) keys.emplace_back(p.first); for (auto k : keys) for (; g[k] >= 2 && h[m - k] >= 1; g[k] -= 2, --h[m - k], ++ans) { } if (m % 2 == 0) { ans += g[m / 2] / 2; g[m / 2] %= 2; } for (auto k : keys) if (k + k < m) ans += min(g[k], g[m - k]); cout << ans << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); while (read()) solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | serezhae |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1241 Byte |
Status | WA |
Exec Time | 89 ms |
Memory | 10620 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, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 9 ms | 640 KB |
01-03.txt | AC | 22 ms | 2176 KB |
01-04.txt | AC | 27 ms | 2688 KB |
01-05.txt | AC | 30 ms | 2816 KB |
01-06.txt | AC | 36 ms | 3328 KB |
01-07.txt | AC | 38 ms | 3456 KB |
01-08.txt | WA | 42 ms | 3712 KB |
01-09.txt | WA | 44 ms | 3840 KB |
01-10.txt | WA | 53 ms | 6656 KB |
01-11.txt | AC | 53 ms | 7680 KB |
01-12.txt | AC | 9 ms | 640 KB |
01-13.txt | AC | 9 ms | 640 KB |
01-14.txt | AC | 25 ms | 2944 KB |
01-15.txt | AC | 36 ms | 4352 KB |
01-16.txt | AC | 46 ms | 5248 KB |
01-17.txt | AC | 49 ms | 5376 KB |
01-18.txt | AC | 51 ms | 5632 KB |
01-19.txt | AC | 55 ms | 6528 KB |
01-20.txt | AC | 89 ms | 10620 KB |
01-21.txt | AC | 14 ms | 768 KB |
01-22.txt | AC | 17 ms | 768 KB |
01-23.txt | AC | 18 ms | 896 KB |
01-24.txt | AC | 19 ms | 896 KB |
01-25.txt | AC | 19 ms | 1152 KB |
01-26.txt | AC | 19 ms | 1152 KB |
01-27.txt | AC | 50 ms | 7680 KB |
01-28.txt | AC | 3 ms | 640 KB |
01-29.txt | AC | 2 ms | 384 KB |
01-30.txt | AC | 1 ms | 256 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |