█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 3394

Problema 0x25 - Suma de un subarreglo grande

  • Autor: juanan150
  • Fecha: 2021-03-12 22:39:30 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.028 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.054 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.022 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.054 s 7 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.025 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.024 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.032 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.03 s 4 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.047 s 9 KBi
#10
Esperando resultado...
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.048 s 9 KBi
#12
Esperando resultado...
#13
Esperando resultado...
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 7, in <module>
    aux_vals.append(aux_vals[i-1]+listn[i])
IndexError: list index out of range
0.045 s 9 KBi
Puntos totales: 0 / 100

Código

N = int(input())
listn = [int(x) for x in input().split()]
cases = int(input())
total = sum(listn)
aux_vals = []
for i in range(N):
    aux_vals.append(aux_vals[i-1]+listn[i])

for _ in range(cases):
    p,q=[int(x) for x in input().split()]
    if p > 0:
        val = aux_vals[q] - aux_vals[p-1]
    else:
        val = aux_vals[q]
    print(val)