Pagini recente » Cod sursa (job #2463466) | Cod sursa (job #171165) | Cod sursa (job #990036) | Cod sursa (job #2784929) | Cod sursa (job #1750079)
#include <stdio.h>
#include <queue>
#include <vector>
using namespace std;
struct cmp {
bool operator()(const pair<int, int> &x, const pair<int, int> &y) {
if (x.first == y.first)
return x.second > y.second;
return x.first > y.first;
}
};
int main() {
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
int N, a, b, pos = 0;
priority_queue<pair<int, int>,vector<pair<int,int> >, cmp> mypq;
vector<bool> erased(100000, false);
scanf("%d", &N);
for (int i = 0; i < N; i ++) {
scanf("%d", &a);
if (a == 1) {
scanf("%d", &b);
mypq.push(make_pair(b, ++ pos));
}
else if (a == 2) {
scanf("%d", &b);
erased[b] = true;
}
else if (a == 3) {
while (erased[mypq.top().second])
mypq.pop();
printf("%d", mypq.top().first);
}
}
return 0;
}