I coded a solution in JAVA(Hotspot 8u112) as provided by codechef IDE,
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
static class FastScanner{
BufferedReader br ;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreElements()){
try {
st = new StringTokenizer(br.readLine()) ;
} catch (IOException ex) {
System.out.println("error") ;
}
}
return st.nextToken() ;
}
int nextInt(){
return Integer.parseInt(next()) ;
}
}
public static void main(String args[]){
FastScanner sc = new FastScanner();
int T=sc.nextInt() ;
int n ;
while(T-->0){
n = sc.nextInt() ;
int[] arr = new int[n] ;
int max=0;
for(int i=0;i<n; ++i){
arr[i] = sc.nextInt()*20 ;
}
for(int i=0;i<n; ++i){
arr[i]-=(sc.nextInt()*10) ;
max=(max<arr[i])?arr[i]:max ;
}
System.out.println(max);
}}
}
But, this encounters a RTE, stated as NZEC
Exception in thread "main" java.lang.NullPointerException
at java.util.StringTokenizer.<init>(StringTokenizer.java:199)
at java.util.StringTokenizer.<init>(StringTokenizer.java:236)
at Codechef$FastScanner.next(Main.java:25)
at Codechef$FastScanner.nextInt(Main.java:35)
at Codechef.main(Main.java:43)
while the same code runs perfectly on my IDE(NeTbeans 9.0).
Can anyone tell-
a) Why so? What care needs to be taken on codechef.
b) How i can fix it?