Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.025 s | 3 KBi |
#2 |
Correcto
|
0.028 s | 7 KBi |
#3 |
Correcto
|
0.019 s | 3 KBi |
#4 |
Correcto
|
0.032 s | 3 KBi |
#5 |
Correcto
|
0.021 s | 3 KBi |
#6 |
Incorrecto
|
0.029 s | 3 KBi |
#7 |
Incorrecto
|
0.021 s | 3 KBi |
#8 |
Incorrecto
|
0.15 s | 5 KBi |
#9 |
Incorrecto
|
0.755 s | 9 KBi |
#10 |
Incorrecto
|
0.798 s | 8 KBi |
#11 |
Incorrecto
|
0.8 s | 8 KBi |
#12 |
Incorrecto
|
0.958 s | 8 KBi |
#13 |
Correcto
|
0.56 s | 9 KBi |
#14 |
Tiempo límite excedido
|
1.556 s | 9 KBi |
a = [] N = 0 C = 0 pq = [] p = 0 q = 0 sum_sub_a = 0 sum_total = 0 N = int(input()) for num in input().split(' '): x = int(num) sum_total += x a.append(x) C = int(input()) for consult in range(C): pq =[] sum_sub_a = 0 p = 0 q = 0 for entry in input().split(' '): y = int(entry) pq.append(y) p = pq [0] q = pq [1] if p==0 and q==N-1: print(sum_total) elif q-p <= N/2: sum_sub_a = sum(a[p:q+1]) print(sum_sub_a) else: sum_0p = sum(a[:p+1]) sum_qn = sum(a[q:N+1]) sum_sub_a = sum_total - sum_0p - sum_qn print(sum_sub_a)