#include

using namespace std;

int main()

{

ios_base::sync_with_stdio(false);

cin.tie(NULL);

int n;

cin>>n;

int a,b;

int dif[2]={0};

for(int i=0;i<n;i++)

{

cin>>a>>b;

if(a>b && (a-b)>dif[1])

{

dif[1]=a-b;

dif[0]=1;

}

else if(b-a>dif[1])

{

dif[1]=b-a;

dif[0]=2;

}

}

cout<<dif[0]<<" "<<dif[1]<<endl;

}

Cumulative lead, not lead per round.

As mentioned by @vijju123, you would need to calculate the cumulative lead after each round and then check for the diff. Currently, with `(a-b)>dif[1]`

and `b-a>dif[1]`

, you are checking for lead in each round.

Try accumulating a’s and b’s individually, say in ‘x’ and ‘y’, and then check for difference of x and y instead of directly checking for the difference of ‘a’ and ‘b’.

Thankyou, I’d missed the “cumulative” in there. Thanks a lot.