Quantcast
Viewing all articles
Browse latest Browse all 40121

getting run time error..please help...i am getting correct output wen i do it on my computer...problem code is DOWNLOAD in easy section

import java.io.; import java.util.;

class alienchef {

/**
 * @param args
 * @throws IOException 
 * @throws NumberFormatException 
 */
public static void main(String[] args) throws NumberFormatException, IOException,IndexOutOfBoundsException {
    // TODO Auto-generated method stub

    int count = 0;
    List<Long> recipe = new ArrayList<Long>();
    List<Double> alien = new ArrayList<Double>();
    List<Long> no_in_group = new ArrayList<Long>();
    BufferedReader abc = new BufferedReader(new InputStreamReader(System.in));
    Long No_recipies = new Long(abc.readLine());
    Scanner abc1 = new Scanner(System.in);
    for(long i=0;i<No_recipies*2;i++){
        recipe.add(new Long(abc1.next()));
    }
    Integer No_groups = new Integer(abc.readLine());
    Scanner abc2 = new Scanner(System.in);
    for(long i=0;i<No_groups;i++){
        no_in_group.add(new Long(abc2.next()));
        int listcount = no_in_group.size();
        long no_of_alien = no_in_group.get(listcount-1);
        for (long j=1;j<=no_of_alien;j++)
        {
            alien.add(new Double(abc2.next()));
        }

    }

    long start=0,end=0;
    int n,m=0;
    end = start+no_in_group.get(m)-1;

         while(start <=end && m<No_groups)
        {   
            List<Long> result = new ArrayList<Long>();
            for(int g=0;g<No_recipies;g++)
            {
                result.add(new Long(0));
            }
             count=0;
            int w = (int)start;
            while(w<=end)
            {
                for(int j=0;j<recipe.size();j=j+2){

                        if(alien.get(w)>=recipe.get(j) && alien.get(w)<=recipe.get(j+1))
                        {   
                            int z = j/2;
                            if(result.get(z)!=1)
                            {
                            count++;
                            result.set(z,new Long(1));
                            }
                        }

                }
                w++;
            }
            start+=no_in_group.get(m);
            if(m+1<No_groups)
                {
                    end+=no_in_group.get(m+1);
                }   
            m++;
            System.out.print(count+"\n");
        }


}

}


Viewing all articles
Browse latest Browse all 40121

Trending Articles



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