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

Envío 3384

Problema 0x25 - Suma de un subarreglo grande

  • Autor: juanan150
  • Fecha: 2021-03-12 17:33:59 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.03 s 3 KBi
#2
Correcto
0.035 s 3 KBi
#3
Correcto
0.029 s 3 KBi
#4
Correcto
0.028 s 3 KBi
#5
Correcto
0.03 s 3 KBi
#6
Correcto
0.036 s 3 KBi
#7
Correcto
0.027 s 3 KBi
#8
Tiempo límite excedido
1.022 s 4 KBi
#9
Tiempo límite excedido
1.055 s 9 KBi
#10
Esperando resultado...
#11
Esperando resultado...
#12
Tiempo límite excedido
1.027 s 9 KBi
#13
Correcto
0.675 s 9 KBi
#14
Tiempo límite excedido
1.063 s 9 KBi
Puntos totales: 58 / 100

Código

N = int(input())
listn = [int(x) for x in input().split()]
cases = int(input())

for _ in range(cases):
    p,q=[int(x) for x in input().split()]
    if p== 0 and q == N:
        print(sum(listn))
    elif p == q:
        print(listn[p])
    else:
        val = listn[p]
        for j in range (p+1,q+1):
            val += listn[j]
        print(val)