-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2493.py
More file actions
29 lines (26 loc) · 751 Bytes
/
2493.py
File metadata and controls
29 lines (26 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from collections import deque
n = int(input())
buildings = list(map(int, input().split()))
answer = []
cur_list = []
dq = deque()
for i in range(len(buildings)):
if not dq:
dq.append((buildings[i], i))
answer.append(0)
continue
# 현재 빌딩이 가장 크다면 레이저가 닿을 수 없음
if dq[0][0] < buildings[i]:
answer.append(0)
dq = deque([(buildings[i], i)])
# 레이저가 닿을 수 있다면
else:
while dq:
height, idx = dq.pop()
if height >= buildings[i]:
answer.append(idx + 1)
dq.append((height, idx))
break
dq.append((buildings[i], i))
for idx in answer:
print(idx, end=' ')