The lead game

, , ,

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;
}

Why are you adding ‘\t’?
Try replacing

printf ("%d\t%d",w,l);

with

printf ("%d %d\n",w,l);

still it is giving wrong answer.

@keshavjee , First of all, as pointed out by @rishabhprsd7 's answer , remove the \t and instead put a space.

But that does not fix it all. Your code does not even give the right output for the sample test case given on the question.

That is, for the input

5
140 82
89 134
90 110
112 106
88 90

The output should be

1 58

But your code gives output

2 58