아직 dp 다풀진않았지만 너무 이것만 붙들고있는거같아서 뒤에도 같이 풀려고 한다.
https://www.acmicpc.net/problem/10828
import sys
N = int(sys.stdin.readline().strip())
num = []
for _ in range(N):
stack = list(sys.stdin.readline().strip().split())
if stack[0] == 'push':
num.append(stack[1])
elif stack[0] == 'pop':
if len(num) != 0:
print(num.pop())
else:
print(-1)
elif stack[0] == 'size':
print(len(num))
elif stack[0] == 'empty':
if len(num) == 0:
print(1)
else:
print(0)
else:
if len(num) != 0:
print(num[-1])
else:
print(-1)
# print(stack)
stack.clear()