1 / 9
Dec 2021

After meticulous testing, I know I have the correct solution, but the judge system always returns a NZEC runtime error. There is literally no place for the error to occur!! Why is this?

Here is my code:

def farida(num, arr):
"""
if num == 1: return arr[0]
memo = [None] * (num)
memo[0] = arr[0]
memo[1] = max(arr[0], arr[1])
for i in range(2, len(memo)): # -----|
memo[i] = max( arr[i], memo[i-2] , arr[i] + memo[i-2] ) # |------- O(N)
if memo[i-1] > memo[i]: memo[i] = memo[i-1] # -----|
return memo[-1]

if __ name __ == ‘__ main __’:
# input test cases
ret = ""
test_cases = int( input().strip() )
if test_cases > 0:
for i in range(test_cases):
num = int( input().strip() )
if num > 0:
arr = list( map(int, input().split(’ ')) )
result = str( farida(num, arr) )
else:
input()
result = str(0)
ret += "Case " + str(i+1) + ": " + result + "\n"
print(ret.strip())

  • created

    Dec '21
  • last reply

    Dec '21
  • 8

    replies

  • 949

    views

  • 2

    users

  • 2

    links

This gives a runtime error when run on IDEONE and given the sample input from the problem.

NameError: name ‘name’ is not defined

FARIDA6

Oops, sorry about that. Fixed it in code (it should be “__ name __”, not “name”)

< underscore >< underscore >name< underscore >< underscore > (no spaces inbetween. The formatting doesn’t show properly here)

Also no spaces in between underscore and name
(IDEONE results below)

If there are zero monsters, then there is no line for their number of coins, so you don’t need to skip the line.

I deleted line 33 as shown in the image with the black background, and your code was then accepted.

I tried doing it, and the same thing happened.
Tried all the different python interpreters too, still nothing.
Even tried different browsers, also nothing.

Take your code from your first post above, but with the correct indentation. Remove that line I indicated - the input() - and submit it. I did this, and it got AC.

I am really sorry, but the issue does not go away. I appreciate your help.

Now I need to know how to report a bug in the judge system. Because there is no other explanation for what’s wrong, ESPECIALLY since you can run my code and I can’t.

I wanted to get a good start for my coding skills because I had lost confidence in mine, which is why I try easy problems. But unneccassary issues like this do not help me at all.