Submission #5429014
Source Code Expand
#include <iostream> #include <string> #include <utility> #include <algorithm> #include <map> #include <set> #include <vector> #include <cmath> #include <cstdlib> #include <queue> #include <stack> #include <iomanip> using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define REPR(i, n) for(ll i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(ll i = 1;i <= n;i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(),n.end() #define MOD 1000000007 #define P pair<ll, ll> ll n, m, cnt[110000], s1[110000], s2[110000], ans; void f(ll i, ll mn) { ll now = mn; now -= min(now, s2[i]); s1[i] -= min(now, s1[i]); ans += s1[i] / 2; } int main() { cin >> n >> m; REP(i, n) { ll a; cin >> a; cnt[a]++; } REP(i, 110000) { if (cnt[i] % 2 == 1)s2[i % m]++; s1[i % m] += cnt[i] - cnt[i] % 2; } REPO(i, (m - 1) / 2) { ll mn = min(s1[i] + s2[i], s1[m - i] + s2[m - i]); ans += mn; f(i, mn); f(m - i, mn); } ans += (s2[0] + s1[0]) / 2; if (m % 2 == 0)ans += (s2[m / 2] + s1[m / 2]) / 2; cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | kenken714 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1221 Byte |
Status | AC |
Exec Time | 31 ms |
Memory | 2560 KB |
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 256 KB |
01-02.txt | AC | 30 ms | 1024 KB |
01-03.txt | AC | 31 ms | 1024 KB |
01-04.txt | AC | 30 ms | 1024 KB |
01-05.txt | AC | 30 ms | 1024 KB |
01-06.txt | AC | 30 ms | 1024 KB |
01-07.txt | AC | 30 ms | 1024 KB |
01-08.txt | AC | 30 ms | 1024 KB |
01-09.txt | AC | 30 ms | 1024 KB |
01-10.txt | AC | 30 ms | 1664 KB |
01-11.txt | AC | 31 ms | 2560 KB |
01-12.txt | AC | 30 ms | 256 KB |
01-13.txt | AC | 30 ms | 640 KB |
01-14.txt | AC | 30 ms | 1024 KB |
01-15.txt | AC | 30 ms | 1024 KB |
01-16.txt | AC | 30 ms | 1024 KB |
01-17.txt | AC | 30 ms | 1024 KB |
01-18.txt | AC | 30 ms | 1024 KB |
01-19.txt | AC | 30 ms | 1280 KB |
01-20.txt | AC | 31 ms | 2560 KB |
01-21.txt | AC | 30 ms | 1024 KB |
01-22.txt | AC | 30 ms | 1024 KB |
01-23.txt | AC | 30 ms | 1024 KB |
01-24.txt | AC | 30 ms | 1024 KB |
01-25.txt | AC | 30 ms | 1536 KB |
01-26.txt | AC | 31 ms | 2560 KB |
01-27.txt | AC | 17 ms | 1792 KB |
01-28.txt | AC | 5 ms | 2560 KB |
01-29.txt | AC | 3 ms | 1664 KB |
01-30.txt | AC | 3 ms | 1152 KB |
sample-01.txt | AC | 2 ms | 256 KB |
sample-02.txt | AC | 2 ms | 256 KB |