CODE FESTIVAL 2016 Final

Submission #992600

Source codeソースコード

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 300000
#define M 100000
int n, m;
int x[N], x2[N];
int y[N];
int z[N];
int w[N], w2[N];
int main(){
	cin>>n>>m;
	rep(i, n) cin>>x[i];
	rep(i, n) x2[x[i]]++;
	rep(i, n) w[i%m] += x2[i]/2;

	rep(i, n) y[x[i]%m]++;
	int res = 0;
	rep(i, m/2+1){
		if(i*2%m==0){
			z[i] = y[i]/2;
			res += z[i];
			z[i] *= 2;

		} else {
			z[i] = z[m-i] = min(y[i], y[m-i]);
			res += z[i];
		}
		//cerr<<i<<" "<<m-i<<" "<<z[i]<<endl;
	}
	//cerr<<res<<endl;
	rep(i, m){
		int t = min(w[i], (y[i]-z[i])/2);
		res += t;
		//cerr<<i<<" "<<t<<endl;
	}
	cout<<res+1<<endl;
	return 0;
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 Lepton_s
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1766 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt WA
01-02.txt WA
01-03.txt WA
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 WA
01-13.txt WA
01-14.txt WA
01-15.txt WA
01-16.txt WA
01-17.txt WA
01-18.txt WA
01-19.txt WA
01-20.txt WA
01-21.txt WA
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt WA
01-28.txt WA
01-29.txt WA
01-30.txt WA
sample-01.txt WA
sample-02.txt WA