Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.02 s | 3 KBi |
#2 |
Correcto
|
0.02 s | 3 KBi |
#3 |
Correcto
|
0.022 s | 3 KBi |
#4 |
Correcto
|
0.017 s | 3 KBi |
#5 |
Correcto
|
0.019 s | 3 KBi |
#6 |
Correcto
|
0.027 s | 8 KBi |
#7 |
Correcto
|
0.022 s | 3 KBi |
#8 |
Tiempo límite excedido
|
1.576 s | 4 KBi |
#9 |
Tiempo límite excedido
|
1.558 s | 8 KBi |
#10 |
Tiempo límite excedido
|
1.564 s | 9 KBi |
#11 |
Tiempo límite excedido
|
1.527 s | 8 KBi |
#12 |
Tiempo límite excedido
|
1.599 s | 9 KBi |
#13 |
Correcto
|
0.374 s | 13 KBi |
#14 |
Tiempo límite excedido
|
1.599 s | 9 KBi |
n = input() input_array = input() array = [int(x) for x in input_array.split()] c = input() n = int(n) c = int(c) outputs = [] sumas = {} def ver_sumas(pq): str_pq = str(pq[0]) + str(pq[1]) if str_pq in sumas: return sumas[str_pq] else: return False def sumar(pq): d = pq[1] - pq[0] res = 0 i = pq[0] str_pq = str(pq[0]) + str(pq[1]) while d >= 0: res = res + array[i] i = i+1 d = d-1 sumas[str_pq] = res return res for i in range(0, c): response = 0 input_pq = input() pq = [int(r) for r in input_pq.split()] is_solved = ver_sumas(pq) if is_solved: response = is_solved else: response = sumar(pq) outputs.append(response) for k in range(0, c): print(outputs[k])