#C7263. Execute Array Commands

    ID: 51115 Type: Default 1000ms 256MiB

Execute Array Commands

Execute Array Commands

You are given a series of commands to manipulate an array. There are three types of commands:

  1. add X: Append the integer (X) to the end of the array.
  2. remove: Remove the last element from the array if the array is not empty.
  3. get i: Retrieve the element at index (i) (0-indexed) from the array.

    Process the commands in the given order and output the result of each get command. The commands dealing with retrieval should output their results to standard output, each on a new line.

inputFormat

The first line contains an integer (n), representing the number of commands. Each of the next (n) lines contains a command, which can be one of the following:

  • add X: where \(X\) is an integer.
  • remove: to remove the last element from the array.
  • get i: where \(i\) is an integer, to retrieve the element at index \(i\) of the array.

outputFormat

For each get command, output the retrieved integer on a separate line.## sample

6
add 5
add 10
get 1
remove
get 0
get 0
10

5 5

</p>