NZEC error

Hi there ,

I was trying to solve this problem , when i ran the solution on my pc using IntelliJ ide it worked just fine , but when i submit the solution on codechef , it gives NZEC error.
Please help me out , i am new here.

Below is the code :

import java.io.*;
public class testt {
public static void main(String[] args)throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int ntest = Integer.parseInt(br.readLine());
    int ae[] = new int[ntest];
    for (int x = 0; x < ntest; x++)
        ae[x] = xyz();
    for (int y = 0; y < ntest; y++) {
        if (ae[y] == 0)
            System.out.println("no");
        else
            System.out.println("yes");

    }
}

    public static int xyz()throws IOException
    {

        BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
        String str=br1.readLine();
        String ar[]=str.split(" ");
        int N=Integer.parseInt(ar[0]);
        int S=Integer.parseInt(ar[1]);
        String str2 = br1.readLine();
        String ar2[]=str2.split(" ");

        int ar21[]=new int[ar2.length];
        for(int y=0;y<ar2.length;y++)
            ar21[y]=Integer.parseInt(ar2[y]);
        int c=0;


        String str23 = br1.readLine();
        String ar23[]=str23.split(" ");
        int ar213[]=new int[ar2.length];
        for(int y=0;y<ar23.length;y++)
            ar213[y]=Integer.parseInt(ar23[y]);

        for(int zz=0;zz<ar23.length;zz++)
        {
            int aq=ar213[zz];
            if(aq==0)
            {
                for(int pp=0;pp<ar23.length;pp++)
                {
                    if(ar213[pp]==1)
                    {
                        int sum=ar21[pp]+ar21[zz];
                        if(sum<=10)
                            c=99;
                    }

                }
            }
            if(aq==1)
            {
                for(int pp=0;pp<ar23.length;pp++)
                {
                    if(ar213[pp]==0)
                    {
                        int sum=ar21[pp]+ar21[zz];
                        if(sum<=10)
                            c=99;
                    }

                }
            }
        }


        if(c==99)
            return 1;
        else
            return 0;

        }



    }

Use try catch in main method like
psvm(String[] args){
try{
your code
}
catch(Exception e){}

1 Like

It is general issue with all new coder in codechef.what you have to do is to provide custom input before clicking on the run button

1 Like

Hey ,
Thank you so much for the reply. Really appreciate it.
I have already tried the same , but it dosen’t work !
Although @rohan_96 suggestion of using try and catch worket.

Also, if not a hassle , can you review my code , i mean is the code too noob ?

Thanks :slight_smile:

And also ,if its not too much to ask , why did i encountered this error , even though it worked fine on my local machine.
Just curious.

Thanks :slight_smile: