Submission #11035078
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) #define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i) #define all(n) begin(n), end(n) using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vc = vector<char>; using vb = vector<bool>; using vd = vector<double>; vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1}; int main() { int n, m; cin >> n >> m; vector<vi> ms(m); rep(i, n) { int x; cin >> x; ms[x % m].push_back(x); } rep(i, m) sort(all(ms[i])); int ans = 0; rep(i, m / 2 + 1) { if(i == 0 || i == m - i) { ans += ms[i].size() / 2; } else { vi s = ms[i]; vi t = ms[m - i]; if(s.size() < t.size()) swap(s, t); int now = 0; rep(j, s.size() - 1) { if(s.size() - now * 2 < t.size() + 2) break; if(s[j] == s[j + 1]) { now++; j++; } } ans += now + t.size(); } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | ryochansq |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1107 Byte |
Status | AC |
Exec Time | 43 ms |
Memory | 5760 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 | 1 ms | 256 KB |
01-02.txt | AC | 36 ms | 892 KB |
01-03.txt | AC | 36 ms | 892 KB |
01-04.txt | AC | 35 ms | 1016 KB |
01-05.txt | AC | 35 ms | 1024 KB |
01-06.txt | AC | 35 ms | 896 KB |
01-07.txt | AC | 34 ms | 768 KB |
01-08.txt | AC | 33 ms | 896 KB |
01-09.txt | AC | 34 ms | 896 KB |
01-10.txt | AC | 40 ms | 2432 KB |
01-11.txt | AC | 43 ms | 4608 KB |
01-12.txt | AC | 32 ms | 1148 KB |
01-13.txt | AC | 33 ms | 2168 KB |
01-14.txt | AC | 35 ms | 788 KB |
01-15.txt | AC | 35 ms | 996 KB |
01-16.txt | AC | 34 ms | 1024 KB |
01-17.txt | AC | 36 ms | 768 KB |
01-18.txt | AC | 34 ms | 1152 KB |
01-19.txt | AC | 36 ms | 1280 KB |
01-20.txt | AC | 42 ms | 5760 KB |
01-21.txt | AC | 34 ms | 832 KB |
01-22.txt | AC | 34 ms | 768 KB |
01-23.txt | AC | 33 ms | 896 KB |
01-24.txt | AC | 33 ms | 896 KB |
01-25.txt | AC | 34 ms | 1664 KB |
01-26.txt | AC | 36 ms | 3328 KB |
01-27.txt | AC | 21 ms | 4096 KB |
01-28.txt | AC | 4 ms | 2688 KB |
01-29.txt | AC | 2 ms | 1152 KB |
01-30.txt | AC | 3 ms | 2560 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |