Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.029 s | 9 KBi |
#2 |
Incorrecto
|
0.021 s | 3 KBi |
#3 |
Incorrecto
|
0.029 s | 3 KBi |
#4 |
Correcto
|
0.027 s | 3 KBi |
#5 |
Correcto
|
0.025 s | 5 KBi |
#6 |
Incorrecto
|
0.458 s | 44 KBi |
#7 |
Incorrecto
|
0.429 s | 42 KBi |
#8 |
Correcto
|
0.477 s | 62 KBi |
#9 |
Incorrecto
|
0.449 s | 46 KBi |
#10 |
Incorrecto
|
0.365 s | 58 KBi |
from collections import deque def looking_to_the_horizon(array, n): stack = deque(maxlen=n) stack.append(-1) tallest_building = array[n - 1] prev_building_height = array[n - 1] for i in reversed(range(n - 1)): current_building_height = array[i] if prev_building_height > current_building_height: tallest_building = prev_building_height stack.append(tallest_building) elif current_building_height > prev_building_height: height_to_append = tallest_building if current_building_height > tallest_building: tallest_building = current_building_height height_to_append = -1 stack.append(height_to_append) else: height_to_append = tallest_building if current_building_height == tallest_building: tallest_building = current_building_height height_to_append = -1 stack.append(height_to_append) prev_building_height = current_building_height return list(reversed(stack)) number_of_cases = int(input()) for i in range(number_of_cases): array_size = int(input()) array = [int(x) for x in input().split()] print("Case #{0}: {1}".format( i + 1, ' '.join(map(str, looking_to_the_horizon(array, array_size)))))