CODE FESTIVAL 2016 Final

Submission #1747958

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] + 1) / 2);
		}
	}
	rc(ans);
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 nibabin
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 1138 Byte
File nameファイル名
Exec time実行時間 44 ms
Memory usageメモリ使用量 11904 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,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 37 ms 9728 KB
01-04.txt AC 38 ms 9728 KB
01-05.txt AC 37 ms 9728 KB
01-06.txt AC 37 ms 9728 KB
01-07.txt AC 37 ms 9728 KB
01-08.txt AC 33 ms 9728 KB
01-09.txt AC 30 ms 9728 KB
01-10.txt AC 23 ms 9984 KB
01-11.txt AC 21 ms 10112 KB
01-12.txt AC 12 ms 6784 KB
01-13.txt AC 12 ms 6784 KB
01-14.txt AC 43 ms 11520 KB
01-15.txt AC 44 ms 11520 KB
01-16.txt AC 42 ms 11520 KB
01-17.txt AC 39 ms 11520 KB
01-18.txt AC 35 ms 11520 KB
01-19.txt AC 30 ms 11520 KB
01-20.txt AC 22 ms 11904 KB
01-21.txt AC 21 ms 7040 KB
01-22.txt AC 20 ms 7040 KB
01-23.txt AC 18 ms 7040 KB
01-24.txt AC 15 ms 7040 KB
01-25.txt AC 14 ms 7040 KB
01-26.txt AC 14 ms 7424 KB
01-27.txt AC 13 ms 9088 KB
01-28.txt AC 4 ms 6912 KB
01-29.txt AC 3 ms 6656 KB
01-30.txt AC 3 ms 6400 KB
sample-01.txt AC 3 ms 6400 KB
sample-02.txt AC 3 ms 6400 KB