#C7263. Execute Array Commands
Execute Array Commands
Execute Array Commands
You are given a series of commands to manipulate an array. There are three types of commands:
add X
: Append the integer (X) to the end of the array.remove
: Remove the last element from the array if the array is not empty.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 eachget
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>