While running the code for the problem Is It A Cakewalk, I am getting a NZEC error. If I run the same code on Eclipse IDE, it is working fine but showing error on CodeChef IDE. Please help. The link to my answer is https://www.codechef.com/viewsolution/23602928
When you run a code on Codechef IDE, you need to give your own inputs by clicking the custom input box near the run button.
Your code had some errors. I fixed it here. They were on lines 13, 35 and 40.
- One line 13, you had System.out.print(“Enter the number of testcases”);. This is not allowed. You only have to print the answer. The input-output has to be exactly what has been specified.
- On lines 35 ad 40, you had System.out.print(), instead of System.out.println(). The answers to different test cases have to be on separate lines. Thus System.out.println() is necessary.
Feel free to ask if anything is unclear. Hope this helped
Thanks a lot. It helped.
Can you help me out with one more question? The problem is Average, and the link to my answer is https://www.codechef.com/viewsolution/23605376. I am getting error:
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 Main.main(Main.java:8)
Uh, check the link your provided. The code isn’t in the language you selected(Java), but in HTML.
Here. I have fixed your code for the problem Average.
Changes -
- Commented System.out.println() in lines 19 and 28.
- In line 33, m got the result of Integer division. Type casted where needed.
- In line 34, (V*(N+K))-sum should be positive, which means greater than 0. So I changed \geq to >. Also that value must be divisible by K.
Thanks a lot.
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 hb=new Scanner(System.in);
int t=hb.nextInt();
while(t-->0)
{
int n=hb.nextInt();
long c=hb.nextLong();
long sum=0;
for(int i=0;i<n;i++)
{
int x=hb.nextInt();
sum+=x;
}
if(sum<=c)
System.out.println("Yes");
else
System.out.println("No");
}
}
}
i have a NZEC error can you please help me out?
Share your submission link which gave you NZEC.