Minimum in the stack#4259

Minimum in the stack

3 sekunt
128 megabaýt
Örän ýeňil

Implement a data structure with the next operations:

  1. Push to the end of the structure.

  2. Pop the last element from the structure.

  3. Print the minimum element in the structure.

Giriş

The first line contains the number of operations (1 \le n \le 10^6). Each of the next lines contains one operation. The -th line contains the number t_i — the type of operation:

  • in the case of a push operation;

  • in the case of a pop operation;

  • if the operation asks to find minimum;

In the case of a push operation, next comes the integer (-10^9 \le x \le 10^9) — element to be inserted into the structure. It is guaranteed that before each pop or getMin operation the structure is not empty.

Çykyş

For each getMin operation, print on a separate line one number — the minimal element in the structure.

Mysallar

1-nji mysal

Loading
Loading