Above lies the link to problem statement.
I’m providing the code below, kindly help me. Thank you…
#include<stdio.h>
int main()
{
int N=0,i=0,W=0,L=0,s=0,t=0;
scanf("%d",&N);
int mS=0,mT=0;
int Si[N],Ti[N],maxS[N],maxT[N];
for(i=0;i<N;i++)
{
Si[i]=0; Ti[i]=0;
scanf("%d %d",&s,&t);
if(i!=0)
{
Si[i]=Si[i-1]+s;
Ti[i]=Ti[i-1]+t;
}
else
{ Si[i]=s;
Ti[i]=t;
}
if(Si[i]>Ti[i])
{ maxS[i]=Si[i]-Ti[i];
if(i==0)
mS=maxS[i];
if(i!=0 && maxS[i]>maxS[i-1])
mS=maxS[i];
}
else
{ maxT[i]=Ti[i]-Si[i];
if(i==0)
mT=maxT[i];
if(i!=0 && maxT[i]>maxT[i-1])
mT=maxT[i];
}
}
if(mS>mT)
{ W=1;L=mS;}
else
{ W=2;L=mT;}
printf("%d %d",W,L);
}