Блог пользователя ahmadhussein19991999

Автор ahmadhussein19991999, история, 13 месяцев назад, По-английски

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.

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.