# what is the problem?

#include<stdio.h>
int main(void)
{int n,s1,s2,k,w,max=0,l,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{scanf("%d%d",&s1,&s2);
if(s1>s2)
{l=s1-s2;
w=1;
}
if(s1<s2)
{l=s2-s1;
w=2;
}
if(l>max)
{max=l;
k=w;
}
}
printf("%d %d",k,max);
return 0;
}

Please read the question once again, you are not calculating the leads correctly. The leads are calculated on the basis of cumulative score, not the current score only. I.e. lets say after round 2, we are calculating the leads on the basis of score for player 1 : score of player1(in round1+round2) and player2= score of player2(in round1+round2). See the same table:

``````Round           Player 1       Player 2     Leader     Lead

1               140           	 82       Player 1     58
2       229(cumulative scores)     216       Player 1     13
3               319           	326       Player 2      7
4               431           	432       Player 2      1
5               519           	522       Player 2      3
``````

Thus, code will go something like this:

``````int i,p1=0,p2=0,w,max=0,maxp,sc,a,b;
for(i=0;i<n;i++)
{
cin>>a>>b;
p1+=a;
p2+=b;
if(p1>p2)
{
sc=p1-p2;
w=1;
}
else
{
sc=p2-p1;
w=2;
}
if(max<sc)
{
max=sc;
maxp=w;
}
//cout<<p1<<" "<<p2<<endl;
}

cout<<maxp<<" "<<max<<endl;
``````

Test case given is such that the way you are doing gives the same answer as the correct way. Probably, thats why you missed it.

Please paste your code in proper indented blocks or give the ideone link.