Submission #6364100
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() { map<int, int> f; auto ans = 0; for (int i = 0; i < n; ++i) if (a[i] % m != 0) ++f[a[i]]; else ++ans; ans /= 2; map<int, int> g, p; for (auto i : f) { p[i.first % m] += i.second / 2; ans += i.second / 2; if (i.second & 1) ++g[i.first % m]; } vector<int> keys; for (auto i : g) keys.emplace_back(i.first); for (auto i : keys) while (g[i] >= 2 && p[(m - i) % m] > 0) { g[i] -= 2; --p[(m - i) % m]; ++ans; } for (auto i : keys) if (i + i < m) ans += min(g[i], g[(m - i) % m]); 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 | 1205 Byte |
Status | WA |
Exec Time | 129 ms |
Memory | 15360 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 | 26 ms | 2688 KB |
01-05.txt | AC | 29 ms | 2816 KB |
01-06.txt | AC | 35 ms | 3328 KB |
01-07.txt | AC | 37 ms | 3456 KB |
01-08.txt | WA | 43 ms | 3712 KB |
01-09.txt | WA | 45 ms | 3840 KB |
01-10.txt | WA | 55 ms | 7164 KB |
01-11.txt | AC | 56 ms | 9344 KB |
01-12.txt | AC | 9 ms | 640 KB |
01-13.txt | AC | 9 ms | 640 KB |
01-14.txt | WA | 24 ms | 2944 KB |
01-15.txt | AC | 35 ms | 4352 KB |
01-16.txt | WA | 45 ms | 5248 KB |
01-17.txt | AC | 53 ms | 5376 KB |
01-18.txt | AC | 55 ms | 5632 KB |
01-19.txt | AC | 61 ms | 6656 KB |
01-20.txt | AC | 129 ms | 15360 KB |
01-21.txt | AC | 13 ms | 768 KB |
01-22.txt | AC | 16 ms | 768 KB |
01-23.txt | AC | 17 ms | 896 KB |
01-24.txt | AC | 18 ms | 896 KB |
01-25.txt | AC | 18 ms | 1152 KB |
01-26.txt | AC | 18 ms | 1152 KB |
01-27.txt | AC | 64 ms | 9984 KB |
01-28.txt | AC | 3 ms | 768 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 |