NZEC error Java ZCO14002

java
java7
java8
nzec
nzecerror
zco

#1

I am using Java and getting NZEC runtime error for task1 all remaining tasks are AC. link to my code:link text
But able to clear all tasks using C.
What is wrong in my java code?
TIA


#2

As far as I can see, it appears to be a problem of the test case. Apparently the length of the array in the input is not always equal to the input value of N. Here is a version of your code (link) that gets AC by keeping track of the number of integers in the input instead of using the given value of N.


#3
n = int(input())
c = [int(x) for x in input().split()]
if len(c) <= 3:
    print(min(c))
else:
    cost = [c[0],c[1],c[2]]
    for i in range(3,len(c)):
        cost.append(c* + min(cost[i-3:i]))
    print(min(cost[len(c)-3:]))

Here this pass all test cases there is a problem in test case, there the give value of n but the element they have given in next line, they are greater or lesser then value of n


#4

Access is denied to that link. We cannot access your code. Either paste your code here or give a link to ide. For ZCO, usually you cannot give link to your solutions.


#5

Rather than pasting your code here, paste your code on text storing sites like pastebin.com or ideone.com and share that link here. But make sure that its public otherwise others won’t be able to see it.


#6

Updated code link.


#7

Thanks you