The Lead Game

Why is claiming my code to be wrong each time ??
My code is :-

import java.util.Scanner;
public class Main {                                     //program for the lead game
public static void main(String args[])
{
Scanner input = new Scanner(System.in); int N=input.nextInt();
int a[]=new int[N]; int b[]=new int[N]; int c[]=new int[N];

for(int i=0;i<N;i++) { a[i]=input.nextInt(); b[i]=input.nextInt(); 
if(a[i]>b[i]) c[i]=a[i]-b[i]; if(a[i]<b[i]) c[i]=b[i]-a[i]; }	


int W=0;
int L=c[0];	 

 for(int i=1 ; i<N ;i++) {
	 if(L<c[i]) L=c[i];
	 if(a[i]>b[i]) W=1; if(a[i]<b[i]) W=2;}  	
 
 if(L==c[0]) {if(a[0]>b[0]) W=1; if(a[0]<b[0]) W=2;}	
	
System.out.print(W+" "+L);	
}
}

You’ve misunderstood the problem. The statement has been edited now to make it more explicit that cumulative scores are considered, and not individual level scores. Please re-read.

1 Like