I am getting NZEC error in my code..
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
/**
*
* @author RAX
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
InputReader in=new InputReader(System.in);
OutputWriter out=new OutputWriter(System.out);
Farida solver=new Farida(in,out);
long t=in.readInt();
for(long i=1;i<=t;i++)
solver.solve(i);
out.close();
}
}
class Farida{
InputReader in;
OutputWriter out;
public Farida(InputReader in ,OutputWriter out){this.in=in;this.out=out;}
public void solve(long test_case){
long a[]=readData();
if(a.length>=2)
a[1]=max(a[0],a[1]);
long temp;
for(int i=2;i<a.length;i++)
{
temp=a[i]+a[i-2];
if(temp>a[i-1])
a[i]=temp;
else
a[i]=a[i-1];
}
out.print("Case "+test_case+": "+a[a.length-1]);
}
private long max(long a,long b){
return (a>b)?a:b;
}
private long[] readData(){
in.readString();// this is for reading the number of monsters
String c[]=in.readString().split(" ");// this will read the number of coins each monster is having
long l[]=new long [c.length];
int count=0;
for (String s:c)
l[count++]= Long.parseLong(s);
return l;
// this will return the array of the coins each monster is having
}
}
class InputReader{
private BufferedReader in;
public InputReader(InputStream in){
this.in=new BufferedReader(new InputStreamReader(in));
}
public String readString(){
String str=null;
try{str=in.readLine();}
catch(IOException e){e.printStackTrace();}
return str;
}
public int readInt(){
String str=null;
try{str=in.readLine();}
catch(IOException e){}
return Integer.parseInt(str);
}
}
class OutputWriter{
private BufferedWriter out;
public OutputWriter(OutputStream out) {
this.out=new BufferedWriter(new OutputStreamWriter(out));
}
public void print(Object ...ob){
try{
for(Object t:ob)
{
out.write(String.valueOf(t));
}
out.write("\n");
}catch(IOException e){}
}
public void close(){
try{
out.close();}
catch(IOException e){}
}
}