#C1313. Dynamic Array Operations

    ID: 42634 Type: Default 1000ms 256MiB

Dynamic Array Operations

Dynamic Array Operations

You are given a dynamic array that supports three operations:

  • append x: Append the integer x to the end of the array.
  • get_last: Remove and output the last element of the array. If the array is empty, output None.
  • get_max: Output the maximum element in the current array. If the array is empty, output None. Note that the maximum is computed as $$\max\{a_1, a_2, \dots, a_n\}.$$

You will be given a number of operations. Process each operation in order and output the result of every get_last and get_max operation on a new line.

inputFormat

The first line contains a single integer Q representing the number of operations to process. The next Q lines each contain one operation in one of the following formats:

  • append x where x is an integer.
  • get_last
  • get_max

It is guaranteed that the input operations are valid.

outputFormat

For each operation that requires an output (get_last and get_max), print the result on a separate line. If an operation is called on an empty array, print None.

## sample
7
append 5
append 10
append 3
get_last
get_max
get_last
get_last
3

10 10 5

</p>