Hi I’m starting with java and i really don’t know about how to use it in codechef and i think my code is right as it is wprking fine in my eclipse ide but this error is poppoing
NZEC
Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Codechef.main(Main.java:12)
My code:
/* package codechef; // don’t place package name! */
import java.util.;
import java.util.Scanner;
import java.lang.;
import java.io.*;
class Codechef {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t= sc.nextInt();
while(t-->0) {
long x=0,l;
int n= sc.nextInt();
int [] arr;
arr=new int[n];
long k= sc.nextLong();
long d=sc.nextLong();
for(int i=0;i<n;i++)
{
arr[i]= sc.nextInt();
x=x+arr[i];
}
if(x<k) {
System.out.println("0");
}
else {
if(x>k) {
l=x/k;
if( l>d) {
System.out.println(d);
}
else {
System.out.println(l);
}
}
else {
l=k/x;
if( l>d) {
System.out.println(d);
}
else {
System.out.println(l);
}
}
}
l=0;
k=0;
x=0;
t--;
}
}
}