We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 51d6357 commit 311633dCopy full SHA for 311633d
1 file changed
live11/test117/문제1/백한결.py
@@ -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