-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2232.py
46 lines (39 loc) · 780 Bytes
/
2232.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 지뢰
import sys
input = sys.stdin.readline
N = int(input())
bombs = [0]
max_bomb = 0
for _ in range(N):
b = int(input())
bombs.append(b)
max_bomb = max(max_bomb, b)
idxs = []
while sum(bombs) > 0:
try:
i = bombs.index(max_bomb)
except:
max_bomb -= 1
continue
idxs.append(i)
lefti = i
righti = i
while True:
if lefti < 1:
break
if bombs[lefti - 1] < bombs[lefti]:
lefti -= 1
else:
break
while True:
if righti > N - 1:
break
if bombs[righti] > bombs[righti + 1]:
righti += 1
else:
break
for i in range(lefti, righti + 1):
bombs[i] = 0
idxs.sort()
for i in idxs:
print(i)