Pagini recente » Cod sursa (job #1255676) | Cod sursa (job #224858) | Cod sursa (job #889460) | Cod sursa (job #348002) | Cod sursa (job #1793078)
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int n,i,x,op;
struct cmp
{
bool operator()(const int &x, const int &y)
{
return x < y;
}
};
vector <int> v;
multiset <int,cmp> heap;
multiset <int,cmp> :: iterator it;
int main( void )
{
freopen("heapuri.in", "r", stdin);
freopen("heapuri.out", "w", stdout);
scanf("%d\n",&n);
for(i=1; i <= n;i++)
{
scanf("%d",&op);
if (op==1)
{
scanf("%d", &x);
v.push_back(x);
heap.insert(x);
}
else
if (op==2)
{
scanf("%d\n", &x);
heap.erase(v[x-1]);
}
else
{
it=heap.begin();
printf("%d\n",*it);
}
}
return 0;
}