其他分享
首页 > 其他分享> > [ AGC002 E ] Candy Piles

[ AGC002 E ] Candy Piles

作者:互联网

题目

Atcoder

思路

1.png
2.png

代码

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 100010;
int n, m, a[N];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1), reverse(a + 1, a + n + 1);
	int t = 0;
	for (int i = 1; i <= n && !t; i++)
		if (i + 1 > a[i + 1]) t = i; // 下一条已经不合法, 当前位置就是对角线终点
	int x = a[t] - t, y = 0;
	while (a[t + y + 1] >= t) y++;
	if ((x & 1) || (y & 1)) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

标签:AGC002,cout,Piles,Atcoder,int,namespace,Candy,100010,include
来源: https://www.cnblogs.com/Proteinlzl/p/14719270.html