My issue
I don’t whats the problem in this code. Why its showing wrong answer while it runs success fully but not passing some cases.
My code
/* 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
{
// your code goes here
Scanner read=new Scanner(System.in);
int n=read.nextInt();
int i=0;
int []T=new int[n];
int [] S=new int[n];
int diff=0;
int max=0;
while((n--)!=0)
{
T[i]=read.nextInt();
S[i]=read.nextInt();
if(T[i]>S[i])
diff=T[i]-S[i];
else
diff=S[i]-T[i];
if(Math.abs(diff)>Math.abs(max))
max=diff; // maxmimum lead changed.
}
if(max>0) //if current lead if greater than maximum lead .means the mamximum lead would be change . winner would also be updated.
System.out.print(1+" "+(max));
else
System.out.print(2+" "+Math.abs(max));
// your code goes here
}
}
Problem Link: TLG Problem - CodeChef