#include<stdio.h>
int main() { int t,w,max,i; scanf("%d",&t);
int a[t],b[t];
for(i=0;i<t;i++)
{
scanf("%d %d",&a[i],&b[i]);}
if(a[0]>b[0])
{
max=a[0]-b[0];
w=1;
}
else
{
max=b[0]-a[0];
w=2;
}for(i=0;i<t;i++)
{if(max<(a[i]-b[i])||max<(b[i]-a[i]))
{
if(a[i]>b[i])
{
max=a[i]-b[i];
w=1;
}
else
{
max=b[i]-a[i];
w=2;
}}
}
printf("%d %d",w,max);return 0;
}
Asked by: Manish_Kumar_Savita on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.
The question wants you to maintain the cumulative lead of a player and wants you to maximise the cumulative lead of any player after any round (not necessarily after the last round).
For example: If the cumulative lead of player A becomes 100 after round 3 and becomes 50 after the last round and the cumulative lead of player B during the course of all rounds never exceeds 100 then only player A wins.