Submission #993341
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for(int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define IINF INT_MAX #define LLINF LLONG_MAX typedef long long ll; typedef pair <int, int> ii; #define DEBUG false int main() { ll n, m; cin >> n >> m; vector <ll> cnt(m); vector <ll> cnt2(m); map <ll, ll> mp; rep(i, n) { ll tmp; cin >> tmp; cnt[(ll) (tmp % m)]++; mp[tmp]++; if(mp[tmp] == 2) { mp[tmp] = 0; cnt2[(ll) (tmp % m)]++; } } ll ans = 0; ans += (ll) (cnt[0] / 2); if(DEBUG) cout << "ans0:" << ans << endl; REP(i, 1, (int) ((m + 1) / 2)) { if(DEBUG) cout << "i:"<<i<<endl; if(cnt[i] > cnt[m - i]) { ll p = cnt[m - i]; ans += p; if(DEBUG) cout << "p:" <<p<<endl; if(cnt2[i] > 0 && cnt[i] - p >= 2) ans += (ll) ((cnt[i] - p) / 2); if(DEBUG) cout << (ll) ((cnt[i] - p) / 2)<<endl; if(DEBUG) cout << "ans1:" << ans << endl; } else { ll p = cnt[i]; ans += p; if(cnt2[m - i] > 0 && cnt[m - i] - p >= 2) ans += (ll) ((cnt[m - i] - p) / 2); if(DEBUG) cout << "ans2:" << ans << endl; } } if(DEBUG) cout << "ans3:" << ans << endl; if(m % 2 == 0) ans += (ll) (cnt[(int) (m / 2)] / 2); if(DEBUG) cout << "ans4:" << ans << endl; cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | letter |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1475 Byte |
Status | WA |
Exec Time | 82 ms |
Memory | 8064 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 256 KB |
01-02.txt | AC | 74 ms | 4224 KB |
01-03.txt | AC | 73 ms | 4224 KB |
01-04.txt | AC | 74 ms | 4224 KB |
01-05.txt | AC | 72 ms | 4224 KB |
01-06.txt | AC | 74 ms | 4224 KB |
01-07.txt | AC | 73 ms | 4224 KB |
01-08.txt | AC | 74 ms | 4224 KB |
01-09.txt | AC | 72 ms | 4224 KB |
01-10.txt | WA | 75 ms | 4864 KB |
01-11.txt | AC | 78 ms | 5760 KB |
01-12.txt | AC | 32 ms | 256 KB |
01-13.txt | AC | 33 ms | 896 KB |
01-14.txt | AC | 79 ms | 6528 KB |
01-15.txt | AC | 77 ms | 6528 KB |
01-16.txt | AC | 77 ms | 6528 KB |
01-17.txt | AC | 78 ms | 6528 KB |
01-18.txt | AC | 77 ms | 6528 KB |
01-19.txt | AC | 82 ms | 6656 KB |
01-20.txt | AC | 80 ms | 8064 KB |
01-21.txt | AC | 51 ms | 512 KB |
01-22.txt | AC | 52 ms | 512 KB |
01-23.txt | AC | 52 ms | 512 KB |
01-24.txt | WA | 52 ms | 512 KB |
01-25.txt | WA | 53 ms | 1024 KB |
01-26.txt | AC | 54 ms | 2048 KB |
01-27.txt | AC | 40 ms | 4992 KB |
01-28.txt | AC | 6 ms | 2048 KB |
01-29.txt | AC | 4 ms | 896 KB |
01-30.txt | AC | 4 ms | 1792 KB |
sample-01.txt | AC | 2 ms | 256 KB |
sample-02.txt | AC | 2 ms | 256 KB |