We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 693043f commit 3263a8eCopy full SHA for 3263a8e
YoonYn9915/implementation/2025-06-21-[백준]-#10828-스택.py
@@ -0,0 +1,30 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
+N = int(input())
5
6
+stack = []
7
+def query():
8
+ Q = input().split()
9
+ if Q[0] == "push":
10
+ stack.append(int(Q[1]))
11
+ elif Q[0] == "pop":
12
+ if len(stack):
13
+ print(stack.pop())
14
+ else:
15
+ print(-1)
16
+ elif Q[0] == "size":
17
+ print(len(stack))
18
+ elif Q[0] == "empty":
19
20
+ print(0)
21
22
+ print(1)
23
+ elif Q[0] == "top":
24
25
+ print(stack[-1])
26
27
28
29
+for _ in range(N):
30
+ query()
0 commit comments