Pagini recente » Cod sursa (job #2117076) | Cod sursa (job #3203028) | Cod sursa (job #922248) | Cod sursa (job #979589) | Cod sursa (job #2066791)
#include <iostream>
#include <set>
#include <vector>
#include <fstream>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
int main()
{
multiset <int>heap;
multiset <int>::iterator it;
vector<int>v;
vector<int>::iterator IT;
int op , q , x;
in >> q ;
for (int i = 0 ; i < q ; ++ i )
{
in >> op ;
if ( op == 1 ){
in >> x ;
heap.insert(x);
v.push_back(x);
}
else if ( op == 2 )
{
int poz ; in >> poz; heap.erase(heap.find(v[poz-1]));
}
else {
it=heap.begin();
out << * it << endl;
}
}
return 0;
}