Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.028 s | 3 KBi |
#2 |
Correcto
|
0.058 s | 3 KBi |
#3 |
Correcto
|
0.025 s | 3 KBi |
#4 |
Correcto
|
0.021 s | 3 KBi |
#5 |
Correcto
|
0.026 s | 3 KBi |
#6 |
Correcto
|
0.024 s | 3 KBi |
#7 |
Correcto
|
0.029 s | 3 KBi |
#8 |
Correcto
|
0.075 s | 4 KBi |
#9 |
Correcto
|
0.481 s | 11 KBi |
#10 |
Correcto
|
0.313 s | 11 KBi |
#11 |
Esperando resultado...
|
||
#12 |
Correcto
|
0.177 s | 11 KBi |
#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 queries = [tuple([int(x) for x in input().split()])for _ in range(c)] for pair in queries: left = pair[0] right = pair[1] prev_sum = 0 if left != 0: prev_sum = a[left - 1] print(a[right] - prev_sum)