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

Envío 3936

Problema 0x25 - Suma de un subarreglo grande

  • Autor: vander idme
  • Fecha: 2021-04-22 23:47:57 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.02 s 3 KBi
#2
Correcto
0.022 s 3 KBi
#3
Correcto
0.027 s 3 KBi
#4
Correcto
0.019 s 3 KBi
#5
Correcto
0.02 s 3 KBi
#6
Correcto
0.019 s 3 KBi
#7
Correcto
0.022 s 3 KBi
#8
Tiempo límite excedido
1.549 s 4 KBi
#9
Tiempo límite excedido
1.536 s 9 KBi
#10
Tiempo límite excedido
1.566 s 9 KBi
#11
Tiempo límite excedido
1.561 s 8 KBi
#12
Tiempo límite excedido
1.532 s 8 KBi
#13
Correcto
0.216 s 9 KBi
#14
Tiempo límite excedido
1.539 s 8 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):
    d = pq[1] - pq[0]
    res = 0
    i = pq[0]
    while d >= 0:
        res = res + array[i]
        i = i+1
        d = d-1

    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])