Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.026 s | 3 KBi |
#2 |
Correcto
|
0.023 s | 7 KBi |
#3 |
Correcto
|
0.024 s | 5 KBi |
#4 |
Correcto
|
0.022 s | 3 KBi |
#5 |
Correcto
|
0.022 s | 3 KBi |
#6 |
Correcto
|
0.023 s | 3 KBi |
#7 |
Correcto
|
0.031 s | 3 KBi |
#8 |
Correcto
|
0.144 s | 4 KBi |
#9 |
Correcto
|
0.733 s | 13 KBi |
#10 |
Correcto
|
0.81 s | 13 KBi |
#11 |
Correcto
|
1.012 s | 8 KBi |
#12 |
Correcto
|
0.982 s | 9 KBi |
#13 |
Correcto
|
0.599 s | 8 KBi |
#14 |
Tiempo límite excedido
|
1.566 s | 8 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-1)/2: sum_sub_a = sum(a[p:q+1]) print(sum_sub_a) else: sum_0p = sum(a[:p]) sum_qn = sum(a[q+1:N+1]) sum_sub_a = sum_total - sum_0p - sum_qn print(sum_sub_a)