k-th element - MarisaOJ: Marisa Online Judge

k-th element

Time limit: 1000 ms
Memory limit: 256 MB
For an array A of n integers, you need to process q queries, each belonging to one of the three types: - 1x: Add the value x to the end of array A. - 2: Remove the last value from array A. It is guaranteed that A has at least one element at this point. - 3k: Find the element with index k in the array, array indices starting from 1. ### Input - The first line consists of two integers n,q. - The second line contains n integers Ai. - The next q lines, each containing a query in the specified format. ### Output - Output an integer as the answer for each type 3 query. ### Constraints - 1≤n,q≤105. - 1≤x≤109. - 1≤k≤|A| where |A| is the length of array A at the time of the query. ### Sample test Input 54123451636232 Output: 62