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

Envío 3935

Problema 0x25 - Suma de un subarreglo grande

  • Autor: vander idme
  • Fecha: 2021-04-22 23:27:32 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.018 s 3 KBi
#2
Correcto
0.022 s 3 KBi
#3
Correcto
0.023 s 3 KBi
#4
Correcto
0.018 s 3 KBi
#5
Correcto
0.018 s 3 KBi
#6
Correcto
0.023 s 3 KBi
#7
Correcto
0.019 s 3 KBi
#8
Tiempo límite excedido
1.555 s 4 KBi
#9
Tiempo límite excedido
1.598 s 9 KBi
#10
Tiempo límite excedido
1.599 s 9 KBi
#11
Tiempo límite excedido
1.553 s 9 KBi
#12
Tiempo límite excedido
1.553 s 9 KBi
#13
Correcto
0.288 s 8 KBi
#14
Tiempo límite excedido
1.54 s 9 KBi
Puntos totales: 58 / 100

Código

n = input()
input_array = input()
array = [int(x) for x in input_array.split()]
c = input()

n = int(n)
c = int(c)

outputs = []


def sumar(pq):
    res = 0
    for j in range(pq[0], pq[1] + 1):
        res = res + array[j]

    return res


for i in range(0, c):
    response = 0
    input_pq = input()
    pq = [int(r) for r in input_pq.split()]
    response = sumar(pq)
    outputs.append(response)

for k in range(0, c):
    print(outputs[k])