Pagini recente » Cod sursa (job #3278367) | Cod sursa (job #695635) | Cod sursa (job #1212742) | Cod sursa (job #3189412) | Cod sursa (job #3246693)
#include <fstream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
int q;
vector<int> add;
map<int, int> fr;
priority_queue<int> H;
int main()
{
f >> q;
for(int i = 1; i <= q; i ++)
{
int tip; f >> tip;
if(tip == 1){
int x; f >> x;
H.push(-x); add.push_back(x);
}
else if(tip == 2){
int x; f >> x;
fr[add[x - 1]] = 1;
}
else{
while(!H.empty() && fr[-H.top()])
H.pop();
g << -H.top() << '\n';
}
}
return 0;
}