The Lead game: Wrong Answer

I dont know what is wrong in the code… Tried for many inputs. Runs fine on ideone.

  #include <iostream>
    #include<cmath>
    using namespace std;
    
int main() {
	int t;
	int x1,y1,min=0,max=0,a;
	scanf("%d",&t);
	for(int i=1;i<=t;i++)
	{
		scanf("%d%d",&x1,&y1);
		a=x1-y1;
		if(a>=max)
		{	max=a;
		}
		if(min>=a)
		{	min=a;
		}
	}
	if(abs(max)>abs(min))
		printf("1 %d",max);
	else
		printf("2 %d",-min);
	return 0;
}

@azimuthal:

U missed an important point, the points of the previous rounds are added to the current round. The lead is calculated only after that(see the table in the question).

  1. Have a variable tx that stores the total points obtained by 1st player(at ith round).

  2. similarly have ty that calculates the total points obtained by 2nd player.

  3. after each round calculate the lead.

AC solution for reference :slight_smile:

1 Like
//