Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.028 s | 5 KBi |
#2 |
Correcto
|
0.028 s | 3 KBi |
#3 |
Correcto
|
0.029 s | 3 KBi |
#4 |
Correcto
|
0.034 s | 5 KBi |
#5 |
Correcto
|
0.034 s | 3 KBi |
#6 |
Correcto
|
0.032 s | 3 KBi |
#7 |
Correcto
|
0.032 s | 5 KBi |
#8 |
Correcto
|
0.08 s | 6 KBi |
#9 |
Tiempo límite excedido
|
0.144 s | 10 KBi |
#10 |
Tiempo límite excedido
|
0.223 s | 12 KBi |
#11 |
Correcto
|
0.322 s | 17 KBi |
#12 |
Tiempo límite excedido
|
0.159 s | 11 KBi |
#13 |
Tiempo límite excedido
|
0.23 s | 13 KBi |
#14 |
Tiempo límite excedido
|
0.209 s | 16 KBi |
n_arr = int(input()) raw_arr = input().split(' ') n_q = int(input()) # Continue loading/parsing just within the range of queries qs = [[0, 0]]*n_q max_idx = 0 for rng in range(n_q): p, q = input().split(' ') p, q = int(p), int(q) qs[rng] = [p, q] max_idx = max(q, max_idx) arr = list(map(int, raw_arr[:max_idx+1])) # Integral array to yield sums in linear time partial = [0]*(max_idx+2) for n, p in enumerate(arr): partial[n+1] = partial[n] + p for q0, q1 in qs: print(partial[q1+1]-partial[q0])