Skip to content

Commit 311633d

Browse files
author
hangyeol
committed
117차 1번 문제풀이
1 parent 51d6357 commit 311633d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
3+
def main():
4+
input = sys.stdin.readline
5+
6+
N = int(input())
7+
towers = list(map(int, input().split()))
8+
stack = []
9+
result = []
10+
11+
for i in range(len(towers)):
12+
while stack and towers[stack[-1]] < towers[i]:
13+
stack.pop()
14+
15+
if stack:
16+
result.append(stack[-1] + 1)
17+
else:
18+
result.append(0)
19+
20+
stack.append(i)
21+
22+
print(*result)
23+
24+
if __name__ == '__main__':
25+
main()

0 commit comments

Comments
 (0)