Pagini recente » Cod sursa (job #2822115) | Cod sursa (job #2936468) | Cod sursa (job #1450833) | Cod sursa (job #3246959) | Cod sursa (job #2801277)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#define INF 100000
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
struct imp
{
int h,v;
};
int n,q,a,nr,l,orm,elm,el[200001];
auto cmp=[](pair <int,int> a,pair <int,int> b){if (a.first<b.first) return 0; else return 1;};
priority_queue <pair<int,int>,std:: vector <pair<int,int>>,decltype (cmp)> heap(cmp);
int main()
{
f>>n;
for (int i=1; i<=n; i++)
{
f>>q;
//cout<<i<<' ';
if (q==1)
{
f>>a;
nr++;
heap.push(make_pair(a,nr));
}
else if (q==2)
{
f>>a;
el[a]=1;
}
else
{
g<<heap.top().first<<'\n';
}
while (!heap.empty() && el[heap.top().second]==1)
heap.pop();
}
return 0;
}