Cod sursa(job #544859)
Utilizator | Data | 2 martie 2011 11:50:36 | |
---|---|---|---|
Problema | Heapuri | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.62 kb |
#include<fstream>
#include<set>
using namespace std;
struct comp {
bool operator()(long i, long j) {
return i<j;
}
};
multiset<long,comp> heap;
long N;
long poz[200005];
int main() {
long t,k=0,x;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
fin>>N;
for(long i=1; i<=N;i++) {
fin>>t;
if(t==1) {
fin>>x;
heap.insert(x);
poz[++k]=x;
}
if(t==2) {
fin>>x;
heap.erase(poz[x]);
}
if(t==3) {
fout<<*heap.upper_bound(0)<<"\n";
}
}
fin.close();
fout.close();
return 0;
}