-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfun_game.cpp
91 lines (87 loc) · 2.18 KB
/
fun_game.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
cin >> t;
while( t > 0)
{
int n;
cin >> n;
vector <int> arr(n);
vector <int> brr(n);
int num;
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
for(int i = 0; i < n; i++)
{
cin >> brr[i];
}
vector <int> crr(n);
for(int i = 0; i < n; i++)
{
crr[i] = arr[i] + brr[i];
}
/*for(int i = 0; i < n; i++)
{
cout << crr[i] << endl;
}*/
int sum1 = 0, sum2 = 0;
int i = 0;
int index1 = 0, index2 =0;
int max,pos;
vector <int> :: iterator it;
while(i < n)
{
max = *max_element(crr.begin(), crr.end());
it = find(crr.begin(), crr.end(), max);
pos = it-crr.begin();
//cout << "MAX : " << max << endl;
sum1 = sum1 + arr[pos];
//cout << "SUM1 : " << sum1 << endl << endl;
//arr.erase(arr.begin() + pos);
crr[pos] = 0;
arr[pos] = 0;
//crr.erase(crr.begin() + pos);
/*for(int i = 0; i < crr.size(); i++)
{
cout << crr[i] << endl;
}*/
i++;
if(i >= n)
break;
max = *max_element(crr.begin(), crr.end());
//cout << "MAX : " << max << endl;
it = find(crr.begin(), crr.end(), max);
pos = it-crr.begin();
//cout << pos << endl;
sum2 = sum2 + brr[pos];
//cout << "SUM2 : " << sum2 << endl << endl;
//brr.erase(brr.begin() + pos);
//crr.erase(crr.begin() + pos);
brr[pos] = 0;
crr[pos] = 0;
i++;
}
if(sum1 == sum2)
{
cout << "Tie" << endl;
}
else if(sum1 > sum2)
{
cout << "First" << endl;
}
else
{
cout << "Second" << endl;
}
t--;
}
return 0;
}