Submission #6363989
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define Int int64_t #define dump(x) cout << (x) << endl #define fi first #define se second Int mod = 1e9+7; Int INF = 1e18; double EPS = 0.00000001; //Int mod = 1e6+3; int main() { Int n, m; cin >> n >> m; vector<map<Int, Int>> v(m); for (Int i = 0; i < n; i++) { Int x; cin >> x; v[x % m][x]++; } vector<Int> vsum(m, 0); vector<vector<Int>> vsum2(m); for (Int i = 0; i < m; i++) { for (auto j : v[i]) { vsum[i] += j.se; vsum2[i].emplace_back(j.se); } sort(vsum2[i].begin(), vsum2[i].end()); } Int res = vsum[0] / 2; for (Int i = 1; i <= m - i; i++) { if (i == m - i) { res += vsum[i] / 2; } else { Int add = min(vsum[i], vsum[m - i]); res += add; if (add == 0 || vsum[i] == vsum[m - i]) continue; Int cnt = 0; if (vsum[i] == add) { for (Int j = 0; j < (Int)vsum2[m - i].size(); j++) { if (cnt >= add) { res += vsum2[i][j] / 2; } else if (cnt + j <= add) { cnt += vsum2[i][j]; } else { res += (vsum2[i][j] - (add - cnt)) / 2; cnt += vsum2[i][j]; } } } else { for (Int j = 0; j < (Int)vsum2[i].size(); j++) { if (cnt >= add) { res += vsum2[i][j] / 2; } else if (cnt + j <= add) { cnt += vsum2[i][j]; } else { res += (vsum2[i][j] - (add - cnt)) / 2; cnt += vsum2[i][j]; } } } } } dump(res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | keep_OC |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2107 Byte |
Status | WA |
Exec Time | 69 ms |
Memory | 17536 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 | 61 ms | 4860 KB |
01-03.txt | AC | 60 ms | 4860 KB |
01-04.txt | WA | 60 ms | 4860 KB |
01-05.txt | WA | 61 ms | 4864 KB |
01-06.txt | WA | 61 ms | 4736 KB |
01-07.txt | WA | 58 ms | 4864 KB |
01-08.txt | WA | 54 ms | 4864 KB |
01-09.txt | WA | 55 ms | 5120 KB |
01-10.txt | WA | 47 ms | 8576 KB |
01-11.txt | WA | 48 ms | 13952 KB |
01-12.txt | WA | 30 ms | 256 KB |
01-13.txt | WA | 32 ms | 3712 KB |
01-14.txt | AC | 67 ms | 7676 KB |
01-15.txt | AC | 69 ms | 7548 KB |
01-16.txt | WA | 68 ms | 7552 KB |
01-17.txt | WA | 67 ms | 7552 KB |
01-18.txt | WA | 58 ms | 8192 KB |
01-19.txt | WA | 53 ms | 8448 KB |
01-20.txt | AC | 54 ms | 17536 KB |
01-21.txt | AC | 39 ms | 512 KB |
01-22.txt | WA | 38 ms | 512 KB |
01-23.txt | WA | 37 ms | 512 KB |
01-24.txt | WA | 34 ms | 640 KB |
01-25.txt | WA | 33 ms | 2944 KB |
01-26.txt | WA | 36 ms | 8448 KB |
01-27.txt | AC | 28 ms | 12800 KB |
01-28.txt | WA | 7 ms | 8320 KB |
01-29.txt | AC | 3 ms | 3456 KB |
01-30.txt | AC | 5 ms | 8064 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |