The Lead Game

import java.util.Scanner;

public class TheLeadGame {

	public static void main(String[] args)
		Scanner one = new Scanner(;
		int N = one.nextInt();
		int leader = 0, total=-1,num = 0, player = 0;
		int[] array = new int[N];
		int[] array2 = new int[N];
		for(int i=0;i<N;i++)
			int W =one.nextInt();
			int L = one.nextInt();
			int lead = Math.abs(W-L);
				leader = 1;
				leader = 2;
			array2[i] = leader;
		for(int j=0;j<N;j++)
				player = array2[j];
		System.out.println(player+"  "+total);
1 Like

The corrected solution:

  1. Don’t create a public class. Codechef throws a RE in such a case.
  2. Always include the question link and your submitted solution link.

Now, considering your solution, your code has a small mistake; the problem asks to calculate the cumulative lead and compare them. You have calculated the current lead.

In other words, you have compared the absolute difference of score of Player A and B in that particular round, but, according to the problem, you need to compare the sum of scores of A and B upto that particular round…

Hope it helps…:slight_smile:

You can create a public class but the name of class has to be Main then.

Thanks, It helped a lot