Submission #7897803
Source Code Expand
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; map<int, int> mp; for (int i = 0; i < n; i++) { int x; cin >> x; mp[x]++; } vector<vector<int>> g(m); vector<int> cnt(m); for (auto x: mp) { g.at(x.first % m).push_back(x.second); cnt.at(x.first % m) += x.second; } int ans = 0; for (int i = 0; i <= m / 2; i++) { if (i == 0 || (i == m - i)) ans += cnt.at(i) / 2; else { vector<int> *s; int cnt_s, cnt_t; if (cnt.at(i) > cnt.at(m - i)) { s = &g.at(i); cnt_s = cnt.at(i); cnt_t = cnt.at(m - i); } else { s = &g.at(m - i); cnt_s = cnt.at(m - i); cnt_t = cnt.at(i); } for (int i = 0; i < (int)s -> size(); i++) { if (cnt_s > cnt_t) { int c = min(s -> at(i) / 2, cnt_s - cnt_t); ans += c; cnt_s -= c; } } ans += cnt_t; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | karyo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1250 Byte |
Status | WA |
Exec Time | 73 ms |
Memory | 10752 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 | 3 ms | 384 KB |
01-02.txt | AC | 58 ms | 3584 KB |
01-03.txt | AC | 59 ms | 3620 KB |
01-04.txt | WA | 60 ms | 3584 KB |
01-05.txt | WA | 58 ms | 3584 KB |
01-06.txt | WA | 59 ms | 3584 KB |
01-07.txt | WA | 59 ms | 3712 KB |
01-08.txt | WA | 59 ms | 3584 KB |
01-09.txt | WA | 60 ms | 3712 KB |
01-10.txt | WA | 62 ms | 5504 KB |
01-11.txt | WA | 65 ms | 7936 KB |
01-12.txt | AC | 29 ms | 256 KB |
01-13.txt | AC | 30 ms | 1408 KB |
01-14.txt | AC | 67 ms | 5500 KB |
01-15.txt | AC | 67 ms | 5632 KB |
01-16.txt | AC | 67 ms | 5632 KB |
01-17.txt | AC | 68 ms | 5504 KB |
01-18.txt | AC | 68 ms | 5760 KB |
01-19.txt | AC | 69 ms | 5888 KB |
01-20.txt | AC | 73 ms | 10752 KB |
01-21.txt | AC | 38 ms | 384 KB |
01-22.txt | WA | 38 ms | 512 KB |
01-23.txt | WA | 38 ms | 512 KB |
01-24.txt | WA | 38 ms | 512 KB |
01-25.txt | WA | 38 ms | 1408 KB |
01-26.txt | WA | 39 ms | 3328 KB |
01-27.txt | AC | 36 ms | 6912 KB |
01-28.txt | WA | 5 ms | 3200 KB |
01-29.txt | AC | 2 ms | 1408 KB |
01-30.txt | AC | 3 ms | 2944 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |