Pagini recente » Cod sursa (job #1592543) | Cod sursa (job #294449) | Cod sursa (job #2206948) | Statistici Manon Bonnet (bonnetm412) | Cod sursa (job #1184071)
#include <fstream>
#include <queue>
#include <vector>
#include <bitset>
using namespace std;
struct nr
{
int x,y;
};
struct comp
{
bool operator() (const nr &a, const nr &b)
{return a.x>b.x;}
};
priority_queue <nr,vector<nr>, comp> H;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
bitset <200001> v;
int main()
{
int n,i,ok,k,cuc=1;
fin>>n;
nr u;
for(i=1;i<=n;i++)
{
fin>>ok;
if(ok==3)
{
while(v[H.top().y]) H.pop();
fout<<H.top().x<<"\n";
}
else
{
fin>>k;
if(ok==1) u.x=k,u.y=cuc,H.push(u);
else v[k]=1;
cuc++;
}
}
}