-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTLG.cpp
68 lines (58 loc) · 982 Bytes
/
TLG.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
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
std::ios::sync_with_stdio(false);
int rounds,j=0,k=0;
cin>>rounds;
int player1[rounds];
int player2[rounds];
abc: for(;j<rounds;)
{
cin>>player1[j];
//cout<<"For player 1: "<<player1[j]<<endl;
j++;
break;
}
for(;k<rounds;)
{
cin>>player2[k];
//cout<<"For player 2: "<<player2[k]<<endl;
k++;
//goto abc;
break;
}
if(j<rounds || k<rounds)
{
goto abc;
}
//Make the changes below:
for(j=1; j<rounds; j++)
{
player1[j] = player1[j] + player1[j-1];
}
for(k=1; k<rounds; k++)
{
player2[k] = player2[k] + player2[k-1];
}
int lead[rounds];
for(int i=0; i<rounds; i++)
{
lead[i] = player1[i] - player2[i];
}
int max,value;
max = lead[0];
value = lead[0];
for (int i=0; i<rounds; i++)
{
if(abs(lead[i]) > max){
max = abs(lead[i]);
value = lead[i];
}
}
if(value>0)
cout<<1<<" "<<max<<endl;
else
cout<<2<<" "<<max<<endl;
}