The link to problem : TLG
My code :
/* PROB - TLG */
#include <stdio.h>
int main(void) {
// your code goes here
int t,win=1,diff=-1,lead=0,s1,s2;
scanf("%d\n", &t);
while(t--)
{
scanf("%d\n", &s1);
scanf("%d\n", &s2);
if(diff==-1)
{
if(s1>s2)
{
lead = diff = s1-s2;
win = 1;
}
else
{
lead = diff = s2-s1;
win = 2;
}
}
else
{
if(s1>s2)
{
diff = s1-s2;
if(diff>lead)
{
lead=diff;
win = 1;
}
}
else
{
diff = s2-s1;
if(diff>lead)
{
win = 2;
lead = diff;
}
}
}
}
printf("%d %d\n", win, lead);
return 0;
}