

import sys
input = sys.stdin.readline
x = []
for i in range(int(input())):
n = list(map(str,input().split()))
if n[0] == 'push':
x.append(int(n[1]))
elif n[0] == 'top':
print(x[-1] if len(x) != 0 else -1)
elif n[0] == 'empty':
print(1 if len(x) == 0 else 0)
elif n[0] == 'size':
print(len(x))
else:
print(-1 if len(x) == 0 else x.pop())
list(map(str,input().split())) 로 안 하고 그냥 input().split()을 했어도 됐을 것 같다
| [파이썬/python] 백준 4949번 : 균형잡힌 세상(🥈3) (0) | 2023.05.26 |
|---|---|
| [파이썬/python] 백준 9012번 : 괄호(🥈4) (0) | 2023.05.26 |
| [파이썬/python] 백준 20920번 : 영단어 암기는 괴로워(🥈3) (0) | 2023.05.26 |
| [파이썬/python] 백준 26069번 : 붙임성 좋은 총총이(🥈4) (0) | 2023.05.25 |
| [파이썬/python] 백준 25192번 : 인사성 밝은 곰곰이(🥈4) (0) | 2023.05.25 |