import sys
stack=[]
n=int(sys.stdin.readline().rstrip())
for i in range(n):
command=sys.stdin.readline().rstrip()
if command[:2]=='pu':
stack.append(int(command[5:]))
if command[:2]=='to':
if len(stack)==0:
print(-1)
else :
print(stack[len(stack)-1])
if command[:2]=='si':
print(len(stack))
if command[:2]=='po':
if len(stack)==0:
print(-1)
else :
print(stack.pop())
if command[:2]=='em':
if len(stack)==0:
print(1)
else :
print(0)
#시간 초과 문제로 pypy3으로 제출함
'백준(BOJ) 풀이' 카테고리의 다른 글
[백준 6064] 카잉 달력 (0) | 2019.11.15 |
---|---|
[백준 1085] 직사각형에서 탈출 (0) | 2019.11.15 |
[백준 2775] 부녀회장이 될테야 (0) | 2019.11.14 |
[백준 10250] 10250 ACM 호텔 (0) | 2019.11.14 |
[백준 1316] 그룹 단어 체커 (0) | 2019.11.14 |