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

Envío 942

Problema 0x25 - Suma de un subarreglo grande

  • Autor: fermed
  • Fecha: 2020-10-03 20:39:55 UTC (Hace más 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 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.031 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 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.026 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 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.034 s 4 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.032 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.031 s 6 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.03 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 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.034 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 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.059 s 5 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.202 s 12 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.195 s 12 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.205 s 12 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.2 s 12 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.201 s 14 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 8, in <module>
    sum = accumulated_sum[-1] + number
IndexError: list index out of range
0.211 s 14 KBi
Puntos totales: 0 / 100

Código

n = int(input())
numbers = list(map(int, input().split()))
assert(n == len(numbers))
c = int(input())
queries = [list(map(int, input().split())) for i in range(c)]
accumulated_sum = []
for number in numbers:
    sum = accumulated_sum[-1] + number
    accumulated_sum.append(sum)

def sub_array_sum(p, q):
    assert(p <= q)
    assert(q <= len(arr))
    if p == q:
        return (accumulated_sum[q])
    return(accumulated_sum[q] - accumulated_sum[p])


for query in queries:
    p, q = query
    print(sub_array_sum(p, q))