[ AGC002 E ] Candy Piles
题目
思路
代码
#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;
}