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

Envío 3382

Problema 0x25 - Suma de un subarreglo grande

  • Autor: juanan150
  • Fecha: 2021-03-12 17:13:26 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.044 s 3 KBi
#2
Correcto
0.033 s 3 KBi
#3
Correcto
0.028 s 3 KBi
#4
Correcto
0.023 s 3 KBi
#5
Correcto
0.022 s 3 KBi
#6
Correcto
0.036 s 3 KBi
#7
Correcto
0.027 s 3 KBi
#8
Tiempo límite excedido
1.056 s 4 KBi
#9
Esperando resultado...
#10
Tiempo límite excedido
1.066 s 9 KBi
#11
Esperando resultado...
#12
Tiempo límite excedido
1.099 s 9 KBi
#13
Esperando resultado...
#14
Tiempo límite excedido
1.094 s 9 KBi
Puntos totales: 50 / 100

Código

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

for i 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:
        list_fin = listn[p:q+1]
        val = sum(list_fin)
        print(val)