-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguests.cpp
More file actions
51 lines (40 loc) · 984 Bytes
/
Copy pathguests.cpp
File metadata and controls
51 lines (40 loc) · 984 Bytes
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void solve(vector<int>guests, int n){
sort(guests.begin(), guests.end());
for(int i = 0; i < n - 2; ++i){
int start = i + 1;
int end = n - 1;
int a = guests[i];
while(start < end){
int b = guests[start];
int c = guests[end];
if(a + b + c == 0){
cout << "Fair" << endl;
return;
}
else if(a + b + c < 0){
start++;
}
else{
end--;
}
}
}
cout << "Rigged" << endl;
}
int main(){
int n;
while(cin >> n){
vector<int>guests;
int el;
for(int i = 0; i < n; ++i){
cin >> el;
guests.push_back(el);
}
cin >> el;
solve(guests, n);
}
}