Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.028 s | 3 KBi |
#2 |
Incorrecto
|
0.022 s | 3 KBi |
#3 |
Correcto
|
0.02 s | 3 KBi |
#4 |
Correcto
|
0.026 s | 3 KBi |
#5 |
Incorrecto
|
0.032 s | 3 KBi |
#6 |
Incorrecto
|
0.384 s | 43 KBi |
#7 |
Correcto
|
0.332 s | 42 KBi |
#8 |
Correcto
|
0.458 s | 55 KBi |
#9 |
Incorrecto
|
0.431 s | 46 KBi |
#10 |
Incorrecto
|
0.472 s | 58 KBi |
def looking_to_the_horizon_no_stack(array, n): result = [-1 for _ in range(n)] tallest_and_nearest_building_height = array[n - 1] previous_building_height = array[n - 1] for building_idx in reversed(range(n - 1)): current_building_height = array[building_idx] if current_building_height >= previous_building_height and current_building_height >= tallest_and_nearest_building_height: tallest_and_nearest_building_height = current_building_height else: result[building_idx] = tallest_and_nearest_building_height previous_building_height = current_building_height return result 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_no_stack(array, array_size)))))