Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.029 s | 3 KBi |
#2 |
Correcto
|
0.027 s | 3 KBi |
#3 |
Correcto
|
0.02 s | 3 KBi |
#4 |
Correcto
|
0.024 s | 3 KBi |
#5 |
Correcto
|
0.028 s | 3 KBi |
#6 |
Correcto
|
0.04 s | 6 KBi |
#7 |
Correcto
|
0.027 s | 3 KBi |
#8 |
Correcto
|
0.13 s | 4 KBi |
#9 |
Correcto
|
0.851 s | 9 KBi |
#10 |
Correcto
|
0.501 s | 9 KBi |
#11 |
Esperando resultado...
|
||
#12 |
Esperando resultado...
|
||
#13 |
Esperando resultado...
|
||
#14 |
Esperando resultado...
|
from itertools import accumulate n = int(input()) # Number of elements in array a = list(accumulate(int(x) for x in input().split())) # Accumulate original array O(n) c = int(input()) # Number of queries for _ in range(c): left, right = [int(x) for x in input().split()] prev_sum = 0 if left != 0: prev_sum = a[left - 1] print(a[right] - prev_sum)