 # Showing wrong answer for correct output

Below is my code for Question

I have tried the below code for various inputs and it is giving me the desired output but while running the code on codechef it says wrong answer.

import java.io.*;
import java.util.StringTokenizer;

class CodeChef_TLG
{

``````public static void main(String[] args) throws IOException
{
String win = "";
int temp = 0;

System.in
)
);

for (int i = 0; i < totalGames; i++)
{
StringTokenizer st = new StringTokenizer(kin.readLine(), " ");
int p1 = Integer.parseInt(st.nextToken());
int p2 = Integer.parseInt(st.nextToken());

lead = (p1 > p2) ? (p1 - p2) : (p2 - p1);

{
win = (p1 > p2) ? "1" : "2";
}
}
System.out.println(win + " " + temp);
}
``````

}

Meaning, if at previous round A was at lead of 20, and at next round B got a lead of 40, then actual/cumulative lead of B now is 40-20 =20, and not 40.

Hi,

According to the last two lines in the below extract from the question it says that the player having maximum lead at the end of any of the round would be the winner.

In his version, at the end of each round the leader and her current lead are calculated. Once all the rounds are over the player who had the maximum lead at the end of any round in the game is declared the winner.

Read the second table carefully Its the lead of cumulative scores, not current round scores.

Hi,

Thank You I have solved the question observing the second table.

What I understood is that cumulative lead / score is score of current round + score of next round except for the first round where the scores are copied as it is.

At first I thought that the second table are new set of scores where in the first round the players scored the same score as in round 1 Please let me know if my interpretation of cumulative lead / score is wrong.

If u got AC it means u r right 