-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpace-Arrays.cpp
51 lines (44 loc) · 1.04 KB
/
Space-Arrays.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// https://www.codechef.com/MARCH21C/problems/SPACEARR
#include <bits/stdc++.h>
#define lli long long int
#define li long int
#define db double
#define f(i, start, end, offset) for( i = start; i < end; i += offset)
using namespace std;
void solution() {
int N, count = 0, temp, i, flag = 0;
cin >> N;
int arr[N], validity[N] = {0};
f(i, 0, N, 1) cin >> arr[i];
sort(arr, arr+N);
if (arr[0] != 1) {
cout << "Second" << endl;
flag = 1;
}
f(i, 0, N, 1) {
if (flag == 1) break;
if (arr[i] > i+1){
cout << "Second" << endl;
flag = 1;
break;
} else {
while(arr[i] < i+1){
count++;
arr[i]++;
}
}
}
if (flag == 0) {
if (count%2 == 0) cout << "Second" << endl;
else cout << "First" << endl;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
long test;
cin >> test;
while (test--) solution();
return 0;
}