Pagini recente » Cod sursa (job #1579472) | Cod sursa (job #684594) | Cod sursa (job #1413559) | Cod sursa (job #1894496) | Cod sursa (job #2066795)
#include <bits/stdc++.h>
using namespace std;
ifstream in("heapuri.in");
ofstream out("heapuri.out");
int loc ;
int main()
{
multiset <int>heap;
multiset <int>::iterator it;
map <int,int>MAP;
int op , q , x;
in >> q ;
for (int i = 0 ; i < q ; ++ i )
{
in >> op ;
if ( op == 1 ){
in >> x ;
heap.insert(x);
MAP[++loc]=x;
}
else if ( op == 2 )
{
in >> x ;
it = heap.find(MAP[x]);
heap.erase(it);
}
else {
it=heap.begin();
out << * it << '\n';
}
}
return 0;
}