Pagini recente » Cod sursa (job #175313) | Cod sursa (job #1715802) | Cod sursa (job #1606970) | Cod sursa (job #13359) | Cod sursa (job #1602884)
#include <iostream>
#include <fstream>
#include <queue>
using namespace std;
ifstream f("heapuri.in");
ofstream g("heapuri.out");
struct elem
{ int x,ord; } el;
struct cmp
{
bool operator() (elem a,elem b)
{ return a.x>b.x; }
};
priority_queue <elem,vector<elem>,cmp> heap;
int n,del[200005];
int main()
{ int i,t,k=0,val;
f>>n;
for(i=1;i<=n;i++)
{ f>>t;
if (t==1) {f>>val; el.x=val; k++; el.ord=k; heap.push(el);}
if (t==2) {f>>val; del[val]=1;}
if (t==3) { while(del[heap.top().ord]) heap.pop(); g<<heap.top().x<<"\n"; }
}
return 0;
}