CODE FESTIVAL 2016 Final

Submission #1747955

Source codeソースコード

# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,M,a[1 << 17],sum[1 << 17];
map<int,int>m[1 << 17];
int ans;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> M;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		m[a[i] % M][a[i]]++;
		sum[a[i] % M]++;
	}	
	for(int i = 0;i <= M / 2;i++)
	{
		if((i == 0) || ((M % 2 == 0) && (i == M / 2))) ans += sum[i] / 2;
		else
		{
			int j = i;
			if(sum[i] < sum[M - i]) j = M - i;
			ans += sum[M - j];
			for(auto it : m[j])
			{
				if((it.second & 1) && sum[M - j])
					sum[M - j]--;
				ans += it.second / 2;
			}
			ans -= (sum[M - j] / 2);
		}
	}
	rc(ans);
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 nibabin
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1132 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 4 ms 6400 KB
01-02.txt AC 38 ms 9728 KB
01-03.txt AC 38 ms 9728 KB
01-04.txt AC 40 ms 9728 KB
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 13 ms 6784 KB
01-13.txt AC 13 ms 6784 KB
01-14.txt AC 44 ms 11520 KB
01-15.txt AC 44 ms 11520 KB
01-16.txt AC 46 ms 11520 KB
01-17.txt AC 45 ms 11520 KB
01-18.txt AC 35 ms 11520 KB
01-19.txt AC 33 ms 11520 KB
01-20.txt AC 24 ms 11904 KB
01-21.txt AC 21 ms 7040 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 13 ms 9088 KB
01-28.txt WA
01-29.txt AC 4 ms 6656 KB
01-30.txt AC 4 ms 6400 KB
sample-01.txt AC 4 ms 6400 KB
sample-02.txt AC 4 ms 6400 KB