Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.025 s | 3 KBi |
#2 |
Incorrecto
|
0.027 s | 3 KBi |
#3 |
Incorrecto
|
0.03 s | 3 KBi |
#4 |
Incorrecto
|
0.034 s | 8 KBi |
#5 |
Incorrecto
|
0.028 s | 3 KBi |
#6 |
Tiempo límite excedido
|
1.039 s | 39 KBi |
#7 |
Tiempo límite excedido
|
1.024 s | 16 KBi |
#8 |
Tiempo límite excedido
|
1.043 s | 53 KBi |
#9 |
Tiempo límite excedido
|
1.06 s | 13 KBi |
#10 |
Tiempo límite excedido
|
1.061 s | 58 KBi |
from collections import deque cases = int(input()) for case in range(cases): n = input() buildings = [int(v) for v in input().split(" ")] result = [] stack = deque([buildings[-1]]) for building in buildings[::-1]: # print(f"building {building}, stack {stack}, top {stack[-1]}", building, stack) if len(stack) > 0 and building < stack[-1]: result.insert(0, stack[-1]) stack.append(building) else: while len(stack) > 0 and building >= stack[-1]: stack.pop() if len(stack) > 0 and building < stack[-1]: result.insert(0, stack[-1]) if len(stack) == 0: result.insert(0, -1) stack.append(building) # print(f"result: {result}") print(f"Case #{case+1}: {result}")