Advertisement
sibinasto

Maximum and Minimum

May 15th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. n = int(input())
  2. numbers = []
  3.  
  4. for _ in range(n):
  5.     tokens = input().split()
  6.     query = tokens[0]
  7.  
  8.     if query == "1":
  9.         num = int(tokens[1])
  10.         numbers.append(num)
  11.  
  12.     elif query == "2" and numbers:
  13.         numbers.pop()
  14.  
  15.     elif query == "3" and numbers:
  16.         print(max(numbers))
  17.  
  18.     elif query == "4" and numbers:
  19.         print(min(numbers))
  20.  
  21.  
  22. print(', '.join(map(str, reversed(numbers))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement