CODE FESTIVAL 2016 Final

Submission #992592

Source codeソースコード

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m;
	cin>>n>>m;
	vi cnt(100010);
	rep(i,n){
		int a;
		cin>>a;
		cnt[a]++;
	}
	vi in1(m),in2(m);
	rep(i,100010){
		int t=cnt[i];
		in1[i%m]+=t%2;
		in2[i%m]+=t/2*2;
	}
//	rep(i,m)cout<<in1[i]<<" "<<in2[i]<<endl;
	int out=(in1[0]+in2[0])/2;
	loop(i,1,(m+1)/2){
		int t=m-i;
		int mi=min(in1[i]+in2[i],in1[t]+in2[t]);
		out+=mi;
		int a=mi;
		a-=in1[i];
		out+=(in2[i]-(a>0?a:0))/2;
		a=mi;
		a-=in1[t];
		out+=(in2[t]-(a>0?a:0))/2;
//		cout<<out<<endl;
	}
	if(m%2==0){
		out+=(in1[m/2]+in2[m/2])/2;
	}
	cout<<out<<endl;
}






Submission

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

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 700 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 4 ms 640 KB
01-02.txt AC 31 ms 640 KB
01-03.txt AC 31 ms 640 KB
01-04.txt AC 31 ms 640 KB
01-05.txt AC 31 ms 640 KB
01-06.txt AC 31 ms 640 KB
01-07.txt AC 31 ms 640 KB
01-08.txt AC 31 ms 640 KB
01-09.txt AC 31 ms 640 KB
01-10.txt AC 31 ms 896 KB
01-11.txt AC 32 ms 1408 KB
01-12.txt AC 31 ms 640 KB
01-13.txt AC 31 ms 1024 KB
01-14.txt AC 31 ms 640 KB
01-15.txt AC 31 ms 640 KB
01-16.txt AC 31 ms 640 KB
01-17.txt AC 31 ms 640 KB
01-18.txt AC 31 ms 640 KB
01-19.txt AC 31 ms 768 KB
01-20.txt AC 32 ms 1408 KB
01-21.txt AC 31 ms 640 KB
01-22.txt AC 31 ms 640 KB
01-23.txt AC 31 ms 640 KB
01-24.txt AC 31 ms 640 KB
01-25.txt AC 31 ms 896 KB
01-26.txt AC 33 ms 1408 KB
01-27.txt AC 18 ms 1408 KB
01-28.txt AC 6 ms 1408 KB
01-29.txt AC 4 ms 896 KB
01-30.txt AC 5 ms 1408 KB
sample-01.txt AC 4 ms 640 KB
sample-02.txt AC 4 ms 640 KB