 I have the below code. This is failing for one of the inputs, where my answer is

2 973 // Codechef says this is wrong.

1 34427 // Codechef says this is correct answer and my answer to the test examples is wrong.

While the problem statements states as below.

"
Input

The first line of the input will contain a single integer N (N ≤ 10000) indicating the number of rounds in the game. Lines 2,3,…,N+1 describe the scores of the two players in the N rounds. Line i+1 contains two integer Si and Ti, the scores of the Player 1 and 2 respectively, in round i. You may assume that 1 ≤ Si ≤ 1000 and 1 ≤ Ti ≤ 1000
"

Since, Si anf Ti both are less than 1000, max difference that can be achieved is 1000 - 0 = 1000. I am not sure how the answer of 34427 is achieved since we are not adding the differences.

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
final String playerOneValue = “1”;
final String playerTwoValue = “2”;

``````	Scanner scan = new Scanner(System.in);
Integer numTests = Integer.parseInt(scan.nextLine());

Integer maxScore = 0;
String betterPlayer = "";

Map<String, Integer> map = new HashMap<>();
map.put(playerOneValue, 0);
map.put(playerTwoValue, 0);

while(numTests-- > 0) {

String line = scan.nextLine();
String[] values = line.split("\\s+");

Integer playerOne = Integer.parseInt(values);
Integer playerTwo = Integer.parseInt(values);

if(playerOne > playerTwo) {
Integer diff = playerOne - playerTwo;
Integer score = map.get(playerOneValue);

if(diff > score) {
map.put(playerOneValue, diff);
}
} else {
Integer diff = playerTwo - playerOne;
Integer score = map.get(playerTwoValue);

if(diff > score) {
map.put(playerTwoValue, diff);
}
}

}

if(map.get(playerOneValue) > map.get(playerTwoValue)) {
maxScore = map.get(playerOneValue);
betterPlayer = playerOneValue;
} else {
maxScore = map.get(playerTwoValue);
betterPlayer = playerTwoValue;
}

System.out.println(betterPlayer + " " + maxScore);

scan.close();
}
``````

}