# The Lead Game , What's wrong with my code ?

The code is for question The Lead Game ,its showing wrong answer while submitting but running perfectly on ideone.com .please help .

``````#include<stdio.h>
int main()
{
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d%d",&a[i],&b[i]);
}
for(i=0;i<t;i++)
{
if(a[i]>b[i])
else
}
for(i=1;i<t;i++)
else
}
for(i=0;i<t-1;i++)
{
for(j=0;j<t-i-1;j++)
{
{
temp2=a[i];
a[i]=a[i+1];
a[i+1]=temp2;
temp3=b[i];
b[i]=b[i+1];
b[i+1]=temp3;
}
}
}
if(a[0]>b[0])
winner=1;
else
winner=2;
return 0;
}``````

For the given testcase, your code may work…but it is not correct.

here you are storing the lead values of each round in the array leader[10000].

Those lead values are actually not a[i]-b[i]…it is actually

the sum of the scores of the player1 upto the "i"th round - the sum of the scores of the player2 till "i"th round…

so take care of that leader[10000]…then your code may give AC for codechef compiler also

If this helps…hope you can upvote and accept the answer…

All the Best

2 Likes
//