Minimum in the stack
Very easy
Execution time limit is 3 seconds
Runtime memory usage limit is 128 megabytes
Implement a data structure with the next operations:
Push to the end of the structure.
Pop the last element from the structure.
Print the minimum element in the structure.
Input
The first line contains the number of operations . Each of the next lines contains one operation. The -th line contains the number — the type of operation:
1 in the case of a push operation;
2 in the case of a pop operation;
3 if the operation asks to find minimum;
In the case of a push operation, next comes the integer — element to be inserted into the structure. It is guaranteed that before each pop or getMin operation the structure is not empty.
Output
For each getMin operation, print on a separate line one number — the minimal element in the structure.
Examples
Input #1
Answer #1
Submissions 6K
Acceptance rate 39%