I have tried with the given logic the problem wants us to provide and is working fine with my test cases. But still I am getting a wrong answer. Here’s my code.
import java.io.*;
public class CodeChef {
public static void main(String[] args) throws Exception {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
int size = Integer.parseInt(read.readLine());
int[] p1 = new int[size];
int[] p2 = new int[size];
int[] leads = new int[size];
int pos = 0;
int max_lead = leads[0];
for (int i = 0; i < size; i++) {
String[] input1 = read.readLine().split(" ");
p1[i] = Integer.parseInt(input1[0]);
p2[i] = Integer.parseInt(input1[1]);
leads[i] = Math.abs(p1[i] - p2[i]);
if (max_lead < leads[i]) {
max_lead = leads[i];
pos = i;
}
}
if (p1[pos] > p2[pos])
System.out.println(1 + " " + max_lead);
else
System.out.println(2 + " " + max_lead);
}
}