why am I getting the wrong answer although my output is correct?!
here’s the Q:https://www.codechef.com/problems/TLG
my code©:
#include <stdio.h>
#include <stdlib.h>
int r;
int main()
{
scanf("%d",&r);
int sc[r][4],i,max1=0,max2=0;
for(i=0;i<r;i++)
{
scanf("%d",&sc[i][0]);scanf("%d",&sc[i][1]);
if(sc[i][0]>sc[i][1])
{
sc[i][2]=(sc[i][0]-sc[i][1]);
sc[i][3]=0;}
else
{
sc[i][3]=(sc[i][1]-sc[i][0]);
sc[i][2]=0;}
}
max1=sc[0][2];
max2=sc[0][3];
for (i=0;i<r;i++)
{
if(sc[i][2]>max1)
{
max1=sc[i][2];
}
if(sc[i][3]>max2)
{
max2=sc[i][3];
}
}
if(max1>max2)
{printf("\n%d",1);printf(" %d",max1);}
else
{printf("\n%d",2);printf(" %d",max2);}
return 0;
}