I have been trying to solve the La Liga Problem “COOK82A” under beginner section. I wrote a code in Java and ran it against the given input along with some inputs of my own and the output was correct. But the compiler of code chef shows error. It would be a big help if somebody can tell me what is the error in the code.
Here is the code.
import java.util.Scanner;
class Laliga {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
String[] teams = new String[4];
int [] teamScore = new int[4];
for(int a = 0;a<n;a++){
for(int i=0;i<4;i++){
String temp = in.next();
int tempS = in.nextInt();
//System.out.println(temp + " "+tempS);
if(temp.equals("Barcelona")){
teams[0] = temp;
teamScore[0] = tempS;
continue;
}
else if(temp.equals("Eibar")){
teams[1] = temp;
teamScore[1] = tempS;
continue;
}
else if(temp.equals("RealMadrid")){
teams[2] = temp;
teamScore[2] = tempS;
continue;
}
else if(temp.equals("Malaga")){
teams[3] = temp;
teamScore[3] = tempS;
continue;
}
}
if(teamScore[0]>teamScore[1]&&teamScore[3]>teamScore[2]){
System.out.println("Barcelona");
}
else
System.out.println("ReadMadrid");
}
in.close();
}
}