Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

what is the nzec error in this code..?

$
0
0

Please tell me the nzec code in this code because i have java on my pc n dis code is running perfectly wid d correct answer there but showing a runtime nzec error in codechef...so plz guide me to detect d error..

import java.io.*;
import java.lang.*;
class Main
{
 public static void main(String args[])throws IOException {
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  int n=Integer.parseInt(br.readLine());
  long s[]=new long[n]; 
  long e[]=new long[n];
  for(int i=0;i<n;i++){
  s[i]=Long.parseLong(br.readLine());  e[i]=Long.parseLong(br.readLine());}
  int q=Integer.parseInt(br.readLine());
  int y[]=new int[q];int ctr=0;
  for(int i=0;i<q;i++)
  {
   int k=Integer.parseInt(br.readLine());long a[]=new long[k];
   for(int j=0;j<k;j++)
   {
    a[j]=Long.parseLong(br.readLine());
   }
   int c=0;
   int h[]=new int[n];
   for(int j=0;j<k;j++)
   {

    if(j==0)
    {
     for(int g=0;g<n;g++){
     if(a[j]>=s[g]&&a[j]<=e[g])
     {
      h[c]=g;c++;
      }
     } }
     else{
    for(int g=0;g<n;g++){

          int p=0;
     if(a[j]>=s[g]&&a[j]<=e[g])
     {
      for(int x=0;x<c;x++)
      if(h[x]==g)
      p++;

      if(p==0){h[c]=g;c++;} else{continue;}
      }
     }
    }
   }
    y[ctr]=c;ctr++;
  }
  for(int i=0;i<ctr;i++)
  System.out.println(y[i]);
 }
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>