Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.026 s | 3 KBi |
#2 |
Correcto
|
0.026 s | 5 KBi |
#3 |
Correcto
|
0.028 s | 3 KBi |
#4 |
Correcto
|
0.021 s | 3 KBi |
#5 |
Correcto
|
0.029 s | 6 KBi |
#6 |
Correcto
|
0.021 s | 3 KBi |
#7 |
Correcto
|
0.035 s | 5 KBi |
#8 |
Correcto
|
0.059 s | 5 KBi |
#9 |
Correcto
|
0.236 s | 14 KBi |
#10 |
Correcto
|
0.23 s | 14 KBi |
#11 |
Correcto
|
0.233 s | 14 KBi |
#12 |
Correcto
|
0.248 s | 14 KBi |
#13 |
Correcto
|
0.276 s | 16 KBi |
#14 |
Correcto
|
0.268 s | 16 KBi |
from itertools import accumulate def subarray_sum(array, queries): accumulation = list(accumulate(array)) for query in queries: i, j = query if i == 0: print(accumulation[j]) else: print(accumulation[j] - accumulation[i - 1]) array_size = int(input()) array = [int(x) for x in input().split()] number_of_queries = int(input()) queries = [[int(x) for x in input().split()] for _ in range(number_of_queries)] subarray_sum(array, queries)