Pagini recente » Cod sursa (job #828190) | Cod sursa (job #1500327) | Cod sursa (job #1885658) | Cod sursa (job #2551471) | Cod sursa (job #1491180)
#include <fstream>
#include <algorithm>
#include <queue>
#include <vector>
#include <unordered_map>
using namespace std;
int v[200000];
unordered_map <int, int> my_hash;
priority_queue <int, vector<int>, greater<int> > my_heap;
int main(int argc, char *argv[]) {
ifstream cin ("heapuri.in");
ofstream cout("heapuri.out");
int n;
cin >> n;
int i, crt = 0;
for (i = 0 ; i < n; ++i) {
int op;
cin >> op;
if (op == 1) {
int val;
cin >> val;
v[crt++] = val;
my_heap.push(val);
} else if (op == 2) {
int val;
cin >> val;
my_hash[v[val - 1]]++;
} else if (op == 3) {
while (my_hash[my_heap.top()] > 0) {
my_hash[my_heap.top()]--;
my_heap.pop();
}
cout << my_heap.top() << "\n";
}
}
cin. close();
cout.close();
return 0;
}