Skip to content

Instantly share code, notes, and snippets.

@ealexisaraujo
Created July 2, 2020 20:02
Show Gist options
  • Save ealexisaraujo/2e4a4827f2c80160d8779f87d4bbcf75 to your computer and use it in GitHub Desktop.
Save ealexisaraujo/2e4a4827f2c80160d8779f87d4bbcf75 to your computer and use it in GitHub Desktop.
stack = []
M = []
for _ in range(int(input())):
d = [int(x) for x in input().split()]
if d[0] == 1:
stack.append(d[1])
M.append(max(d[1], M[-1])
if M else d[1])
elif d[0] == 2:
stack.pop()
M.pop()
elif d[0] == 3:
print(M[-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment