why it give 'wrong' output answer for "the lead game question"

#include<stdio.h>
int main()
{
int q,i,a,b,c,d,max=0;
scanf("%d\n",&q);
for(i=0;i<q;i++)
{
scanf("%d %d",&a,&b);
c=abs(a-b);
if(c>max)
{
max=c;
if(a>b)
d=1;
else
d=2;}
}
printf("%d %d\n",d,max);
return 0;
}

Please give forums a search.

Read the Q carefully, the lead means CUMULATIVE LEAD. The lead of previous rounds will be carried over.

Eg- if A has lead of 50 in last round, and B gets lead 80 next round. Then overall lead is 80-50 = 30 for B, and NOT 80. You need to consider lead of previous rounds as well.