My issue
I was looking into some unsolved problems and my code is running just fine but it is not getting submitted only so please look into it.
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 sc=new Scanner(System.in);
int n=sc.nextInt();
int cum_score_1=0;
int cum_score_2=0;
int max=0;
int leader=0;
for(int i=0;i<n;i++){
int a=sc.nextInt();
int b=sc.nextInt();
cum_score_1+=a;
cum_score_2+=b;
if(Math.abs(cum_score_1-cum_score_2)>max){
if(cum_score_1>cum_score_2){
max=cum_score_1-cum_score_2;
leader=1;
}else{
max=cum_score_2-cum_score_1;
leader=2;
}
}
}
System.out.println((leader)+" "+max);
}
}
Problem Link: TLG Problem - CodeChef