Pagini recente » Cod sursa (job #2580476) | Cod sursa (job #391323) | Cod sursa (job #945700) | Cod sursa (job #193174) | Cod sursa (job #1929215)
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ifstream cin("heapuri.in");
ofstream cout("heapuri.out");
cin.tie(0);
ios_base::sync_with_stdio(false);
int q;
cin >> q;
priority_queue<int> Heap, Erased;
vector<int> Elements;
while(q--> 0) {
int type;
cin >> type;
if(type == 1) {
int x;
cin >> x;
Elements.push_back(x);
Heap.push(-x);
} else if(type == 2) {
int idx;
cin >> idx;
Erased.push(-Elements[idx - 1]);
} else {
while(!Heap.empty() && !Erased.empty() && Heap.top() == Erased.top()) {
Heap.pop();
Erased.pop();
}
cout << -Heap.top() << '\n';
}
}
return 0;
}