Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.037 s | 7 KBi |
#2 |
Correcto
|
0.042 s | 3 KBi |
#3 |
Correcto
|
0.035 s | 3 KBi |
#4 |
Correcto
|
0.028 s | 4 KBi |
#5 |
Correcto
|
0.025 s | 3 KBi |
#6 |
Tiempo límite excedido
|
0.75 s | 47 KBi |
#7 |
Correcto
|
0.571 s | 43 KBi |
#8 |
Correcto
|
0.573 s | 58 KBi |
#9 |
Tiempo límite excedido
|
0.703 s | 47 KBi |
#10 |
Correcto
|
0.533 s | 61 KBi |
def case(n_arr, arr): stack = [] view_heights = [-1] * n_arr for idx, height in enumerate(arr[::-1]): idx = n_arr - idx - 1 while len(stack) > 0: lst_height = stack[-1] if height >= lst_height: _ = stack.pop() else: view_heights[idx] = lst_height stack.append(height) break else: stack.append(height) view_heights[idx] = -1 return view_heights if __name__ == "__main__": num_cases = int(input()) for case_nr in range(1, num_cases+1): n_arr = int(input()) arr = list(map(int, input().split(' '))) view_heights = case(n_arr, arr) print(f'Case #{case_nr}: ' + ' '.join(map(str, view_heights)))