# ---------- Import ----------
import sys
input = sys.stdin.readline
# ---------- Main ----------
_ = int(input())
buildings = list(map(int, input().split()))
stack = []
for idx, now in enumerate(buildings):
while stack and stack[-1][0] < now:
stack.pop()
if stack:
print(stack[-1][1], end=" ")
else:
print(0, end=" ")
stack.append((now, idx + 1))
'PS > 자료 구조' 카테고리의 다른 글
[백준] No.2493 탑 01 (0) | 2023.08.23 |
---|