fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. cin >> N;
  7. vector<int>a(N+2);
  8. for(int i = 0; i < N; i++) {
  9. cin >> a[i];
  10. }
  11. sort(a.rbegin(),a.rend());
  12. if(a[1] == 1 && a[0]%2 == 1 && N%2 == 1) {
  13. cout << "Second" << endl;
  14. return 0;
  15. }
  16. int r = N;
  17. for(int i = 0; i <= N; i++) {
  18. while(r && a[r-1] == i) {
  19. r--;
  20. }
  21. if(i+1 == r) {
  22. if((a[i]-i)%2 == 1) {
  23. cout << "Second" << endl;
  24. return 0;
  25. }
  26. }
  27. if(a[i] == i+1) {
  28. if(i <= r && (r-i)%2 == 1) {
  29. cout << "Second" << endl;
  30. return 0;
  31. }
  32. }
  33. }
  34. int sum = a[0];
  35. bool f1 = false,f2 = false;
  36. for(int i = 0; i < N; i++) {
  37. sum -= a[i]-a[i+1];
  38. if(sum-i-3 >= 0 && (sum-i-3)%2 == 1 && sum-a[i+1]+a[i+2]-i-3 <= 0) {
  39. f1 = true;
  40. }
  41. if(i >= 1) {
  42. if(sum-i+1 >= 0 && (sum-i+1)%2 == 1 && sum-a[i+1]+a[i+2]-i+1 <= 0) {
  43. f2 = true;
  44. }
  45. }
  46. }
  47. if(a[1] <= 2 && a[0] >= 3 && a[0]%2 == 1) {
  48. f1 = true;
  49. }
  50. if(f1 && f2) {
  51. cout << "Second" << endl;
  52. return 0;
  53. }
  54. cout << "First" << endl;
  55. }
Success #stdin #stdout 0.01s 5360KB
stdin
Standard input is empty
stdout
First