Java code failing w RuntimeException BUT its passing fine in an online compiler

Revision en1, by rkat7, 2024-05-06 16:29:30

I hope it is ok to be pasting the code as it is the very first problem.

import java.util.*;
public class Ladders1{

    public static void main(){
        Scanner sc = new Scanner(System.in).useDelimiter("\n");
        int t = sc.nextInt();
        int a=0,b=0,c=0;
        for(int i=0;i<t;i++){
            String cords = sc.next();
            String[] xyz = cords.split(" ",0);
            a+=Integer.parseInt(xyz[0]);
            b+=Integer.parseInt(xyz[1]);
            c+=Integer.parseInt(xyz[2]);


        }

        if(a==0 && b==0 && c==0){
            System.out.println("YES");
        } else{
            System.out.println("NO");
        }

    }


}

Would really appreciate your input as I've been trying to find the issue to no avail.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rkat7 2024-05-06 16:29:30 885 Initial revision (published)