the lead game ..why am i getting wrong answer ...??? plzzz help :(

#include<stdio.h>
int main()
{
int n,i,leader,sum1=0,sum2=0,largest,l=0;
scanf("%d",&n);
int ply1[n],ply2[n],lead[n];
for(i=1;i<=n;i++)
{
scanf("%d",&ply1[i]);
scanf("%d",&ply2[i]);

}
for(i=1;i<=n;i++)
{
	if(ply1[i]>ply2[i])
		lead[i]=ply1[i]-ply2[i];
	else
		lead[i]=ply2[i]-ply1[i];
}
largest=lead[1];
for(i=2;i<n;i++)
{
	if(largest<lead[i])
	{
		largest=lead[i];
		l=i;		
	}
}
if(ply1[l]>ply2[l])
printf("1 %d",largest);
else
printf("2 %d",largest);
return 0;

}

Found it! Firstly, change your logic, see the sample test in the question, it talks about cumulative difference in the rounds(take previous scores added up till that score).
Change your code here :-

for(i=2;i<n;i++)
{
if(largest<lead[i])
{
largest=lead[i];
l=i;
}
}

change i<n to i<=n
Also at the time of declaring the array, declare it as ply1[10001] and ply2[10001] because arrays are declare with constant size. Maximum value of index can go upto 10000 hence the size can go upto 10001. Also initial value of l should be 1 not 0 because you are doing 1 based indexing.

http://www.codechef.com/viewsolution/4168516 I have modified your solution to get it correct.

hey…i didn’t get it…see i still didn’t understood why we are taking cumulative difference.on adding the previous score with the second one i got the difference of 71 which is greater than 58…
so…could you please make me understand

//