CODE FESTIVAL 2016 Final

Submission #5874296

Source codeソースコード

#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);swap(nx,ny);}
		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

Task問題 D - Pair Cards
User nameユーザ名 mnrutd
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 629 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 1 ms 256 KB
01-02.txt AC 30 ms 2168 KB
01-03.txt AC 31 ms 1892 KB
01-04.txt WA
01-05.txt WA
01-06.txt WA
01-07.txt WA
01-08.txt WA
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt AC 31 ms 2168 KB
01-13.txt AC 43 ms 5236 KB
01-14.txt AC 31 ms 1892 KB
01-15.txt AC 42 ms 3184 KB
01-16.txt AC 40 ms 2432 KB
01-17.txt AC 41 ms 2176 KB
01-18.txt AC 47 ms 3072 KB
01-19.txt AC 55 ms 3456 KB
01-20.txt AC 84 ms 12032 KB
01-21.txt AC 31 ms 1992 KB
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt AC 56 ms 9984 KB
01-28.txt WA
01-29.txt AC 9 ms 3328 KB
01-30.txt AC 24 ms 8064 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB