eolymp
bolt
Try our new interface for solving problems
Problems

Minimum in the stack

Minimum in the stack

Implement a data structure with the next operations: \begin{enumerate} \item Push $x$ to the end of the structure. \item Pop the last element from the structure. \item Print the minimum element in the structure. \end{enumerate} \includegraphics{https://static.e-olymp.com/content/e8/e8b80c354dd1cbff444c6392d88e484fb42ec425.gif} \InputFile The first line contains the number of operations $n\:(1 \le n \le 10^6)$. Each of the next $n$ lines contains one operation. The $i$-th line contains the number $t_i$ --- the type of operation: \begin{itemize} \item 1 in the case of a \textbf{push} operation; \item 2 in the case of a \textbf{pop} operation; \item 3 if the operation asks to find minimum; \end{itemize} In the case of a \textbf{push} operation, next comes the integer $x\:(-10^9 \le x \le 10^9)$ --- element to be inserted into the structure. It is guaranteed that before each \textbf{pop} or \textbf{getMin} operation the structure is not empty. \OutputFile For each \textbf{getMin} operation, print on a separate line one number --- the minimal element in the structure.
Time limit 3 seconds
Memory limit 128 MiB
Input example #1
8
1 2
1 3
1 -3
3
2
3
2
3
Output example #1
-3
2
2