Cod sursa(job #603972)
| Utilizator | Data | 19 iulie 2011 16:21:13 | |
|---|---|---|---|
| Problema | Heapuri | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <set>
using namespace std;
int n, tip, x, nh=0,v[200010];
multiset <int, less<int> > heap;
int main(){
ifstream f("heapuri.in");
ofstream g("heapuri.out");
f>>n;
for (int i=1;i<=n;i++){
//scanf("%d", &tip);
f>>tip;
if (tip==3) g<<*heap.begin()<<"\n";
if (tip==1) {f>>x;heap.insert(x);++nh;v[nh]=x;}
if (tip==2) {f>>x;multiset <int, less<int> >::iterator it;it=heap.find(v[x]);heap.erase(it);}
}
return 0;
}
