-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleadGame.cpp
More file actions
52 lines (37 loc) · 835 Bytes
/
leadGame.cpp
File metadata and controls
52 lines (37 loc) · 835 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
52
// Solution to this problem: https://www.codechef.com/problems/TLG.
#include <iostream>
#include <vector>
using namespace std;
int main() {
// your code goes here
int n;
cin >> n;
int first = 0;
int second = 0;
int player;
int lead = 0;
int curr;
for (int i = 1; i <= n; ++i) {
int fir;
int sec;
cin >> fir >> sec;
first = first + fir;
second = second + sec;
curr = first - second;
fir = 0 ;
sec = 0;
if (curr >= 0) {
if (curr > lead) {
lead = curr;
player = 1;
}
} else {
curr = second - first;
if (curr > lead) {
lead = curr;
player = 2;
}
}
};
cout << player << " " << lead << endl;
}