Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.031 s | 3 KBi |
#2 |
Correcto
|
0.023 s | 3 KBi |
#3 |
Correcto
|
0.024 s | 3 KBi |
#4 |
Correcto
|
0.023 s | 3 KBi |
#5 |
Correcto
|
0.025 s | 3 KBi |
#6 |
Correcto
|
0.021 s | 3 KBi |
#7 |
Correcto
|
0.022 s | 3 KBi |
#8 |
Correcto
|
0.074 s | 5 KBi |
#9 |
Correcto
|
0.284 s | 14 KBi |
#10 |
Correcto
|
0.346 s | 13 KBi |
#11 |
Correcto
|
0.293 s | 13 KBi |
#12 |
Correcto
|
0.29 s | 13 KBi |
#13 |
Correcto
|
0.361 s | 15 KBi |
#14 |
Correcto
|
0.306 s | 15 KBi |
n = input() size = int(n) array = size *[0] total_a = size *[0] adition_a = 0 number = input() args = number.split() c = input() query_number = int(c) p = query_number *[0] q = query_number *[0] for i in range (0,size): array[i] = int(args[i]) for i in range(0,query_number): query_pq= input() token = query_pq.split() p[i]=int(token[0]) q[i]=int(token[1]) adition = 0 for i in range(0,size): adition = adition + array[i] total_a[i] = adition i =0 for i in range(0,query_number): adition_a = 0 if int(p[i])== 0: adition_a = total_a[q[i]] if int(p[i]) == q[i]: adition_a = array[q[i]] if int(q[i]) > int(p[i]) and int(p[i])!= 0: adition_a = total_a[q[i]] - total_a[p[i]-1] print(adition_a)