Submission #5874218


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;
		for(int j=0;j<y-1;j++){
			sort(begin(div[y]),end(div[y]));
			if(div[y][j]==div[y][j+1]){pr++;j++;}
		}
		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 637 Byte
Status
Exec Time 2104 ms
Memory 11904 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 31 ms 2168 KB
01-03.txt 31 ms 1892 KB
01-04.txt 33 ms 2236 KB
01-05.txt 31 ms 2044 KB
01-06.txt 36 ms 2304 KB
01-07.txt 39 ms 1920 KB
01-08.txt 138 ms 2432 KB
01-09.txt 349 ms 2432 KB
01-10.txt 159 ms 5504 KB
01-11.txt 161 ms 8064 KB
01-12.txt 127 ms 2168 KB
01-13.txt 127 ms 2168 KB
01-14.txt 31 ms 1892 KB
01-15.txt 35 ms 2032 KB
01-16.txt 42 ms 2432 KB
01-17.txt 99 ms 2176 KB
01-18.txt 418 ms 3072 KB
01-19.txt 2103 ms 3456 KB
01-20.txt 346 ms 11904 KB
01-21.txt 31 ms 1992 KB
01-22.txt 34 ms 2136 KB
01-23.txt 43 ms 2176 KB
01-24.txt 220 ms 2432 KB
01-25.txt 139 ms 2688 KB
01-26.txt 137 ms 2688 KB
01-27.txt 2104 ms 6656 KB
01-28.txt 98 ms 640 KB
01-29.txt 98 ms 256 KB
01-30.txt 96 ms 256 KB
sample-01.txt 1 ms 256 KB
sample-02.txt 96 ms 256 KB