# Problem in "The Lead Game" ?

Codechef is showing wrong answer everytime I submit though the program is running fine,may you please point out my flaw

#include<stdio.h>
int main()
{
int n,dif;
scanf("%d",&n);
scanf("%d%d",&q,&w);
if(q>w)
{
}
else
{
}

``````for(i=2;i<=n;++i)
{
scanf("%d%d",&q,&w);
dif=q-w;
if(q>w)
{
}
if(w>q)
{
dif=dif*(-1);
}

}
return 0;
``````

}

You are not interpreting the inputs as expected in the problem statement.Please read the problem statement once again carefully.Hope this helps!!

You are not adding the previous score to the current score . You should add the previous score to the current score to calculate the lead .

Why do we have to add previous score to current score.

rounds=input()
p1_score=[]
p2_score=[]
difference_array=[]
for i in xrange(0,rounds):
a, b = map(int, raw_input().split())
p1_score.append(a)
p2_score.append(b)
for t in range(0,rounds):
difference=p1_score[t]-p2_score[t]
difference_array.append(difference)
difference_array.sort()
x1=abs(difference_array[0])
x2=abs(difference_array[rounds-1])
if x1>x2:
print “2”, x1
elif x2>x1:
print “1”, x2
else:
pass

This is the code I wrote in Python 2.7. Please tell me what’s wrong with this. Test case works fine with it.

```#include
#include
int main(void){
int  n, p=1;
scanf("%d",&n);
if(n>10^4 || n<=0)
exit(0);
int a[n][2], d[n];
for (int i = 0; i < n; ++i)
{
scanf("%d %d",&a[i][0],&a[i][1]);
if(a[i][0]>1000 || a[i][0]<1 || a[i][1]>1000 || a[i][1]<1 )
exit(0);
d[i]=abs(a[i][0]-a[i][1]);
if (d[i]0)
{
d[i]=d[i-1];
a[i][0]=a[i-1][0];
a[i][1]=a[i-1][1];
}
}
if(a[n-1][1]>a[n-1][0])
p++;
printf("%d %d",p,d[n-1]);
}

```