ahmadhussein19991999's blog

By ahmadhussein19991999, history, 13 months ago, In English

when I submit a solution for 1221A problem, I got "Runtime error on test 1". Although there is/are no problems for my code running. Could you tell me what should I do.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

The culprit is the line

for j in range(n):
    nums.append(int(input()))

for example in the sample testcase, you're trying to turn the string "1024 512 64 512" (the numbers are given in one line) into an int which is not possible, you should instead do something like

for num in input().split():
    nums.append(int(num))

to split the string (default delimiter is " ") and go through each number.

also as a general tip, whenever you run into a Runtime Error, using custom invocation gives you more info on what your code is doing.