import sys
n=int(sys.stdin.readline().rstrip());s=[]
for _ in range(n):
i=input()
if i.__contains__("push"):
v= list(map(str,i.split()))[1]
s.append(v)
elif i=='top':
if s:print(s[-1])
else:print(-1)
elif i=='size':
print(len(s))
elif i=='empty':
if not s:print(1)
else:print(0)
elif i=='pop':
if s:
s.pop()
else:print(-1)
결과 : 시간초과
- 어째서지?..
'알고리즘 > 백준' 카테고리의 다른 글
백준 Python - 1316 그룹 단어 체커 (0) | 2021.02.14 |
---|---|
백준 Python - 2941 크로아티아 알파벳 (0) | 2021.02.12 |
순열과 조합 정복하기! 백준 15649~15666번 (0) | 2021.02.10 |
백준 Python - 1931 회의실 배정 (0) | 2021.02.10 |
백준 Python - 11399 ATM (0) | 2021.02.08 |