Submission #3363781
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int main() { //cout.precision(10); int n, m; cin >> n >> m; map<int, int> mp; for(int i = 1; i <= n; i++){ int in; cin >> in; mp[in]++; } int odds[100500]; int evens[100500]; for(int i = 1; i <= 100000; i++){ int number = i % m; evens[number] += (mp[i] / 2) * 2; if(mp[i] % 2 == 1){ odds[number]++; } } int ans = 0; //for(int i = 1; i <= 1; i++){ for(int i = 1; i * 2 < m; i++){ int number = min(odds[i], odds[m - i]); ans += number; odds[i] -= number; odds[m - i] -= number; //cout << ans << endl; number = min(odds[i], evens[m - i]); ans += number; //cout << ans << endl; odds[i] -= number; evens[m - i] -= number; number = min(evens[i], odds[m - i]); ans += number; //cout << ans << endl; evens[i] -= number; odds[m - i] -= number; ans += evens[i] / 2; ans += evens[m - i] / 2; //cout << i << " " << ans << endl; } ans += odds[0] / 2; evens[0] += (odds[0] % 2); ans += evens[0] / 2; if(m % 2 == 0){ int check = m / 2; ans += odds[check] / 2; evens[check] += (evens[check] % 2); ans += evens[check] / 2; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | kort0n |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1589 Byte |
Status | WA |
Exec Time | 76 ms |
Memory | 5760 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 | WA | 37 ms | 4992 KB |
01-02.txt | WA | 72 ms | 4992 KB |
01-03.txt | WA | 72 ms | 4992 KB |
01-04.txt | WA | 72 ms | 4992 KB |
01-05.txt | WA | 72 ms | 4992 KB |
01-06.txt | WA | 72 ms | 4992 KB |
01-07.txt | WA | 72 ms | 4992 KB |
01-08.txt | WA | 72 ms | 4992 KB |
01-09.txt | WA | 72 ms | 4992 KB |
01-10.txt | WA | 72 ms | 5248 KB |
01-11.txt | WA | 73 ms | 5760 KB |
01-12.txt | WA | 66 ms | 4992 KB |
01-13.txt | WA | 62 ms | 5248 KB |
01-14.txt | WA | 75 ms | 4992 KB |
01-15.txt | WA | 75 ms | 4992 KB |
01-16.txt | WA | 76 ms | 4992 KB |
01-17.txt | WA | 75 ms | 4992 KB |
01-18.txt | WA | 75 ms | 4992 KB |
01-19.txt | WA | 75 ms | 4992 KB |
01-20.txt | WA | 75 ms | 5760 KB |
01-21.txt | WA | 57 ms | 4992 KB |
01-22.txt | WA | 58 ms | 4992 KB |
01-23.txt | WA | 58 ms | 4992 KB |
01-24.txt | WA | 57 ms | 4992 KB |
01-25.txt | WA | 58 ms | 5120 KB |
01-26.txt | WA | 58 ms | 5760 KB |
01-27.txt | WA | 49 ms | 5760 KB |
01-28.txt | WA | 23 ms | 5760 KB |
01-29.txt | WA | 19 ms | 5248 KB |
01-30.txt | WA | 28 ms | 5760 KB |
sample-01.txt | WA | 33 ms | 4992 KB |
sample-02.txt | WA | 37 ms | 4992 KB |