Skip to content

Commit f40f026

Browse files
author
hangyeol
committed
115차 2번 문제풀이
1 parent 886404b commit f40f026

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)