Submission #5874263


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)

signed main(){
	int n,m;cin>>n>>m;
	vector<int>x(n);
	for(auto&& u:x)cin>>u;
	map<int,vector<int>> div;
	for(auto&& u:x)div[u%m].push_back(u);
	int ret=0;
	ret+=div[0].size()/2;
	if(m%2==0)ret+=div[m/2].size()/2;
	for(int i=1;i<=(m-1)/2;i++){
		int x=i,y=m-x;
		int nx=div[x].size(),ny=div[y].size();
		if(nx>ny)swap(x,y);
		ret+=nx;
		int pr=0;
		map<int,int>cnt;
		for(auto&& u:div[y])cnt[u]++;
		for(auto&& u:cnt)pr+=u.second/2;
	
		ret+=min(ny-nx,pr);
	}
	cout<<ret<<endl;

}

Submission Info

Submission Time
Task D - Pair Cards
User mnrutd
Language C++14 (GCC 5.4.1)
Score 0
Code Size 618 Byte
Status
Exec Time 86 ms
Memory 12032 KB

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt
all 0 / 700 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 1 ms 256 KB
01-02.txt 30 ms 2168 KB
01-03.txt 31 ms 1892 KB
01-04.txt 39 ms 3120 KB
01-05.txt 36 ms 2752 KB
01-06.txt 39 ms 2400 KB
01-07.txt 38 ms 2048 KB
01-08.txt 41 ms 2432 KB
01-09.txt 44 ms 2432 KB
01-10.txt 67 ms 5888 KB
01-11.txt 84 ms 11008 KB
01-12.txt 31 ms 2168 KB
01-13.txt 43 ms 5236 KB
01-14.txt 31 ms 1892 KB
01-15.txt 42 ms 3184 KB
01-16.txt 40 ms 2432 KB
01-17.txt 41 ms 2176 KB
01-18.txt 47 ms 3072 KB
01-19.txt 55 ms 3456 KB
01-20.txt 86 ms 12032 KB
01-21.txt 34 ms 2000 KB
01-22.txt 34 ms 2136 KB
01-23.txt 35 ms 2176 KB
01-24.txt 38 ms 2432 KB
01-25.txt 49 ms 4608 KB
01-26.txt 66 ms 10112 KB
01-27.txt 58 ms 9984 KB
01-28.txt 24 ms 8192 KB
01-29.txt 9 ms 3328 KB
01-30.txt 25 ms 8064 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 1 ms 256 KB