# Help me in solving TLG problem

### My issue

why my code is not working… its giving correct test case

### My code

``````#include <iostream>
using namespace std;

int main() {
int t;
cin >> t;
int max_lead = 0;

int a[t], b[t];
bool _2isWinner = true;

for (int i = 0; i < t; i++) {
cin >> a[i] >> b[i];
if (a[i] > b[i] && a[i] - b[i] > max_lead) {
max_lead = a[i] - b[i];
_2isWinner = false;
}
if (b[i] > a[i] && b[i] - a[i] > max_lead) {
max_lead = b[i] - a[i];
}
}

cout << (!_2isWinner ? 1 : 2) << " " << max_lead;
return 0;
}

``````

Problem Link: TLG Problem - CodeChef

@prathamsch77
Actually u have to keep adding the previous rounds score to the next round and then perform your calculations.
plzz refer my code for better understanding

``````#include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main() {

int t;
cin>>t;

int win = 0;
int maxDifence=0;
int FScore=0;
int SScore=0;
while(t--)
{
int first,second;
cin>>first >>second;
FScore+=first;
SScore+=second;

int diference= FScore-SScore;

if (diference > maxDifence)
{
maxDifence=diference;
win = 1;
}
else if(diference<0&&abs(diference)>maxDifence)
{
maxDifence= -diference;
win = 2;
}
//if(FScore==SScore) win=0;
}

cout << win << " " << maxDifence << endl;
return 0;
}``````