Submission #7610191
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(int argc, char* argv[]){ int n,m; cin >> n >> m; vector<vector<int>> x(m, vector<int>(0)); for(int i = 0; i < n ; i++){ int a; cin >> a; if(a % m == 0) x[0].push_back(a); else x[a%m].push_back(a); } int ans = 0; for(int i = 0; i < (x.size() - x.size()%2)/2 + 1; i++){ if(i%m == 0) ans += (x[0].size() - (x[0].size()%2))/2; else if((i * 2) % m == 0) ans += (x[i].size() - x[i].size()%2)/2; else{ int a,b; if(x[i].size() > x[m-i].size()){ a = i; b = m - i; } else{ a = m - i; b = i; } ans += x[b].size(); int count = 0; sort(x[a].begin(), x[a].end()); for(int j = 0; j < x[a].size()-1 ; j++){ if(x[a].size() - x[b].size() >= count+2){ if(x[a][j] == x[a][j+1]){ count ++; j++; } } else break; } ans += count; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | minmin408 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1074 Byte |
Status | WA |
Exec Time | 41 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 | AC | 1 ms | 256 KB |
01-02.txt | AC | 30 ms | 892 KB |
01-03.txt | AC | 30 ms | 892 KB |
01-04.txt | WA | 33 ms | 896 KB |
01-05.txt | WA | 32 ms | 768 KB |
01-06.txt | WA | 32 ms | 896 KB |
01-07.txt | WA | 32 ms | 768 KB |
01-08.txt | WA | 32 ms | 896 KB |
01-09.txt | WA | 33 ms | 896 KB |
01-10.txt | WA | 38 ms | 2432 KB |
01-11.txt | WA | 41 ms | 4608 KB |
01-12.txt | AC | 32 ms | 892 KB |
01-13.txt | AC | 33 ms | 1916 KB |
01-14.txt | AC | 31 ms | 788 KB |
01-15.txt | AC | 32 ms | 896 KB |
01-16.txt | AC | 32 ms | 1024 KB |
01-17.txt | AC | 32 ms | 768 KB |
01-18.txt | AC | 33 ms | 1152 KB |
01-19.txt | AC | 35 ms | 1280 KB |
01-20.txt | AC | 39 ms | 5760 KB |
01-21.txt | AC | 30 ms | 768 KB |
01-22.txt | WA | 32 ms | 768 KB |
01-23.txt | WA | 31 ms | 896 KB |
01-24.txt | WA | 32 ms | 896 KB |
01-25.txt | WA | 34 ms | 1664 KB |
01-26.txt | WA | 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 |