I am continuously getting NZEC error on submitting this problem in Java
import java.util.Scanner;
public class MKBUDGET4SPOJ {
public static void main(String a[]){
Scanner s = new Scanner(System.in);
int count = 0;
while(true){
String line = s.nextLine() ;
String[] split = line.split(" ");
int totalMonths = Integer.parseInt(split[0]);
if(totalMonths == 0)
break ;
long hiringCost = Long.parseLong(split[1]);
long dailyWage = Long.parseLong(split[2]);
long terminationCost = Long.parseLong(split[3]) ;
int[] employeeByMonths = new int[totalMonths+1];
int maxEmployees = -1 ;
for(int i=1 ; i<=totalMonths ; ++i){
employeeByMonths[i] = Integer.parseInt(split[3+i]);
maxEmployees = maxEmployees > employeeByMonths[i] ? maxEmployees : employeeByMonths[i] ;
}
long[][] cost = new long[totalMonths+1][maxEmployees+1];
for(int i= employeeByMonths[1] ; i<= maxEmployees ; ++i)
cost[1][i] = (hiringCost+(long)dailyWage)*((long)i) ;
for(int i=2 ; i<=totalMonths ; ++i){
for(int j=employeeByMonths[i] ; j<=maxEmployees ;++j){
cost[i][j] = 20000000000L;
for(int k=employeeByMonths[i-1] ;k<=maxEmployees ; ++k){
cost[i][j] = Math.min(cost[i][j], cost[i-1][k] + (j>k ? (j-k)*(long)hiringCost :(k-j)*(long)terminationCost) + ((long)j)*dailyWage) ;
// System.out.prlongln("cost " + i + " "+ j + " " +k + " " +cost[i][j]);
}
//System.out.prlongln("cost " + i + " "+ j + " " + cost[i][j]);
}
}
long min = 20000000000L;
for(int i=employeeByMonths[totalMonths] ; i <=maxEmployees ; ++i)
min = Math.min(min, cost[totalMonths][i]);
count++ ;
System.out.println("Case "+count +", " +"cost = " + "$"+min);
}}
}
Any clue regarding the same?