# Help me in solving TLG problem

### My issue

The code seems good but it is giving one wrong answer. I can’t find what is it. Can anybody help me to solve this issue?

#include<stdio.h>
int main()
{
int n,a,b,i,pos;
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
scanf(“%d%d”,&a,&b);
if(a>b)
p[i]=1;
else
p[i]=2;
if(a==b)
else
lead[i] = a > b ? a-b : b-a;
}
pos=0;
for(i=1;i<n;i++)
{
pos = i;
}

}

### My code

``````#include<stdio.h>
int main()
{
int n,a,b,i,pos;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
if(a>b)
p[i]=1;
else
p[i]=2;
if(a==b)
else
lead[i] = a > b ? a-b : b-a;
}
pos=0;
for(i=1;i<n;i++)
{
pos = i;
}

}
``````

Problem Link: TLG Problem - CodeChef

@murali_barla
U have to keep summing up the previous round score to the next round and them compare them .
plzz refer the following code

``````#include <stdio.h>
int main(void) {
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d",&a[i],&b[i]);
}
int sum1=0,sum2=0;
for(i=0;i<n;i++)
{
sum1+=a[i];
sum2+=b[i];
if(sum1>sum2)
{
win[i]=1;
}
else{
win[i]=2;
}
}
int w=0,l=0;
for(i=0;i<n;i++){