here is my code, have tried many corner test cases i read in comments and on other forums, getting correct output on my compiler, but wrong answer on codechef
#include<stdio.h>
int fastread()
{
int input;
char c=0;
while (c<33) c=getchar();
input=0;
while (c>33)
{
input=input*10+c-'0';
c=getchar();
}
return input;
}
int main()
{
int t,i,j,k,l,max,loc=1;
int lead=0,suma=0,sumb=0;
int a[10001][5];
int leader[10001],win[10001];
t=fastread();
for(i=0;i<t;i++)
{
for(j=0;j<2;j++)
a[i][j]=fastread();
}
for(k=0;k<t;k++)
{
j=0;
suma=suma+a[k][j];
sumb=sumb+a[k][j+1];
lead=suma-sumb;
if(lead>0)
{
win[k]=1;
leader[k]=lead;
}
else
{
win[k]=2;
leader[k]=~lead+1;
}
}
max=leader[0];
for(k=1;k<t;k++)
{
if(leader[k]>max)
{
max=leader[k];
loc=k;
}
l=win[loc];
}
printf("%d%d",l,max);
return 0;
}