Submission #7134801
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair<LL,LL> P; const LL mod=1000000007; const LL LINF=1LL<<60; const int INF=1<<30; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; int main(){ int n,m;cin >> n >> m; vector<int> x(n),v(m,0),vv(m,0); map<int,int> ma; for(int i=0;i<n;i++){ cin >> x[i]; ma[x[i]]++; v[x[i]%m]++; } for(auto p:ma){ vv[p.fs%m] += p.sc / 2; } LL ans = 0; for(int i=0;i<=m/2;i++){ if((m%2==0&&i==m/2)||i==0){ ans += v[i] / 2; } else{ if(v[i]<v[m-i]){ ans += v[i]; ans += min(vv[m-i],(v[m-i] - v[i]) / 2); } else{ ans += v[m-i]; ans += min(vv[i],(v[i] - v[m-i]) / 2); } } } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pair Cards |
User | Yukly |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1109 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 6144 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 | 59 ms | 3584 KB |
01-03.txt | AC | 59 ms | 3584 KB |
01-04.txt | AC | 59 ms | 3584 KB |
01-05.txt | AC | 59 ms | 3584 KB |
01-06.txt | AC | 59 ms | 3584 KB |
01-07.txt | AC | 59 ms | 3584 KB |
01-08.txt | AC | 59 ms | 3584 KB |
01-09.txt | AC | 59 ms | 3584 KB |
01-10.txt | AC | 60 ms | 3968 KB |
01-11.txt | AC | 61 ms | 4352 KB |
01-12.txt | AC | 30 ms | 640 KB |
01-13.txt | AC | 30 ms | 1024 KB |
01-14.txt | AC | 67 ms | 5376 KB |
01-15.txt | AC | 67 ms | 5376 KB |
01-16.txt | AC | 68 ms | 5376 KB |
01-17.txt | AC | 70 ms | 5376 KB |
01-18.txt | AC | 69 ms | 5376 KB |
01-19.txt | AC | 80 ms | 5376 KB |
01-20.txt | AC | 69 ms | 6144 KB |
01-21.txt | AC | 39 ms | 768 KB |
01-22.txt | AC | 39 ms | 768 KB |
01-23.txt | AC | 39 ms | 768 KB |
01-24.txt | AC | 39 ms | 768 KB |
01-25.txt | AC | 39 ms | 1024 KB |
01-26.txt | AC | 40 ms | 1536 KB |
01-27.txt | AC | 33 ms | 3584 KB |
01-28.txt | AC | 4 ms | 1152 KB |
01-29.txt | AC | 2 ms | 640 KB |
01-30.txt | AC | 2 ms | 1024 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |