Cod sursa(job #893985)
| Utilizator | Data | 26 februarie 2013 19:05:19 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.77 kb |
#include<iostream>
#include<fstream>
#include<set>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
multiset <int> hp;
multiset <int> :: iterator it;
int main ()
{ int v[200001],nro,op,p=0;
in>>nro ;
for(int i=1; i<=nro; ++i)
{
in>>op;
if(op!=3)
in>>v[++p];
else
{ if(!hp.empty())
{ it=hp.begin();
out<<*it<<'\n';
}
}
if(op==1)
hp.insert(v[p]);
else
if(op==2 && !hp.empty() )
{
hp.erase(v[v[p]]);
}
}
in.close();
out.close();
return 0;
}
