CODE FESTIVAL 2016 Final

Submission #5874218

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);
		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

Task問題 D - Pair Cards
User nameユーザ名 mnrutd
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 0
Source lengthソースコード長 637 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 31 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 RE
01-11.txt RE
01-12.txt RE
01-13.txt RE
01-14.txt AC 31 ms 1892 KB
01-15.txt AC 35 ms 2032 KB
01-16.txt AC 42 ms 2432 KB
01-17.txt AC 99 ms 2176 KB
01-18.txt AC 418 ms 3072 KB
01-19.txt TLE
01-20.txt RE
01-21.txt AC 31 ms 1992 KB
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt RE
01-26.txt RE
01-27.txt TLE
01-28.txt RE
01-29.txt RE
01-30.txt RE
sample-01.txt AC 1 ms 256 KB
sample-02.txt RE