I am getting a runtime error

cakewalk

#1

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


#2

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 :slight_smile:


#3

Here. I have fixed your code for the problem Average.
Changes -

  1. Commented System.out.println() in lines 19 and 28.
  2. In line 33, m got the result of Integer division. Type casted where needed.
  3. 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.

#4

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?


#5

Thanks a lot. It helped.


#7

Uh, check the link your provided. The code isn’t in the language you selected(Java), but in HTML.


#8

Thanks a lot.


#9

Share your submission link which gave you NZEC.