Pagini recente » Cod sursa (job #3281975) | Cod sursa (job #645241) | Cod sursa (job #2971955) | Cod sursa (job #2627585) | Cod sursa (job #1969433)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
ifstream f("heapuri.in"); ofstream g("heapuri.out");
priority_queue <pair <int,int> > q;
int n, c, nr; bool a[200005];
pair <int,int> k;
int main() {
int i;
f>>n;
nr = 0;
for(i = 1; i <= n; ++i) {
f>>c;
if (c == 1) {
f>>k.first;
k.first = -k.first;
++nr;
k.second = nr;
q.push(k);
}
if (c == 2) {
f>>k.first;
a[k.first] = 1;
}
if (c == 3) {
while(a[q.top().second]) {
q.pop();
}
g<<-q.top().first;
}
}
return 0;
}