Submission #992062
Source Code Expand
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
int same(vector<int> &v){
unordered_map<int,int> cnt;
int re=0;
for(int x:v) ++cnt[x];
for(pii p:cnt) re+=p.Y/2;
return re;
}
int main(){
ios_base::sync_with_stdio(false);
cout<<fixed<<setprecision(0);
int n,m;
cin>>n>>m;
vector<int> a(n);
rep(i,n) cin>>a[i];
vv<int> vs(m);
for(int x:a) vs[x%m].pb(x);
int re=vs[0].size()/2;
//cout<<vs[0]<<endl;
reps(i,1,m){
if(m-i<=i) break;
vector<int> &v=vs[i];
vector<int> &w=vs[m-i];
//cout<<v<<w<<same(w)<<endl;
if(v.size()>w.size()) swap(v,w);
re+=v.size()+max<int>((w.size()-v.size())/2,same(w));
}
if(m%2){
//cout<<vs[m/2]<<endl;
re+=vs[m/2].size()/2;
}
cout<<re<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Pair Cards |
User |
nuip |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2226 Byte |
Status |
WA |
Exec Time |
29 ms |
Memory |
6144 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 |
WA |
3 ms |
256 KB |
01-02.txt |
WA |
13 ms |
1276 KB |
01-03.txt |
WA |
12 ms |
1276 KB |
01-04.txt |
WA |
16 ms |
2040 KB |
01-05.txt |
WA |
15 ms |
1920 KB |
01-06.txt |
WA |
16 ms |
1408 KB |
01-07.txt |
WA |
16 ms |
1152 KB |
01-08.txt |
WA |
17 ms |
1280 KB |
01-09.txt |
WA |
17 ms |
1408 KB |
01-10.txt |
WA |
25 ms |
2816 KB |
01-11.txt |
WA |
29 ms |
4992 KB |
01-12.txt |
AC |
14 ms |
1276 KB |
01-13.txt |
AC |
15 ms |
2300 KB |
01-14.txt |
WA |
12 ms |
1172 KB |
01-15.txt |
WA |
18 ms |
2060 KB |
01-16.txt |
WA |
17 ms |
1408 KB |
01-17.txt |
WA |
18 ms |
1152 KB |
01-18.txt |
WA |
19 ms |
1536 KB |
01-19.txt |
WA |
21 ms |
1792 KB |
01-20.txt |
AC |
29 ms |
6144 KB |
01-21.txt |
WA |
12 ms |
1280 KB |
01-22.txt |
WA |
13 ms |
1152 KB |
01-23.txt |
WA |
14 ms |
1280 KB |
01-24.txt |
WA |
14 ms |
1280 KB |
01-25.txt |
WA |
17 ms |
2048 KB |
01-26.txt |
WA |
20 ms |
3712 KB |
01-27.txt |
AC |
20 ms |
4352 KB |
01-28.txt |
WA |
7 ms |
2688 KB |
01-29.txt |
WA |
4 ms |
1152 KB |
01-30.txt |
AC |
6 ms |
2560 KB |
sample-01.txt |
AC |
3 ms |
256 KB |
sample-02.txt |
AC |
3 ms |
256 KB |