# Help me in solving TLG problem

### My code

``````#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= first-second;

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

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

``````

Problem Link: TLG Problem - CodeChef

@astyr1ks
few logical mistakes
hope u will get it
include <bits/stdc++.h>
include
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;
``````

}

Thanks bro.