Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stack>
- #include <iostream>
- using namespace std;
- int main() {
- cin.tie(0);
- ios_base::sync_with_stdio(0);
- int n;
- cin >> n;
- stack<long long> first;
- stack<long long> second;
- long long min_elem = 100000 * 10000 + 1;
- for (int i = 0; i < n; i++) {
- int x;
- cin >> x;
- if (x == 1) {
- int y;
- cin >> y;
- first.push(y);
- if (y <= min_elem) {
- min_elem = y;
- second.push(y);
- }
- else {
- second.push(min_elem);
- }
- }
- if (x == 2) {
- if (first.top() == second.top()) {
- second.pop();
- }
- first.pop();
- }
- if (x == 3) {
- cout << second.top() << endl;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement