I am new to code chef and trying The Lead Game .I can’t figure out why my code is getting a wrong answer , even when it is giving the desired output.
#include <stdio.h>
int main()
{
int n,w,l=0,lead,total1=0,total2=0;
int score1=0;
int score2=0;
scanf("%d",&n);
if (n<=10000)
{
for (n;n>0;n–)
{
scanf("%d\t%d",&score1,&score2);
if (score1<=1000 && score2<=1000)
{
total1 = score1 + total1;
total2 = score2 + total2;
}
if (total1 > total2)
{
lead = total1 - total2;
if(lead>l)
l=lead;
w = 1;
}
else if (total1 < total2)
{
lead = total2 - total1;
if(lead>l)
l=lead;
w = 2;
}
else continue;
}
printf ("%d\t%d",w,l);
}
return 0;
}