Pagini recente » Rating cosmetic tour (cosmetictour) | Cod sursa (job #2292375)
#include <fstream>
#include <set>
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
const int NMAX=200000;
struct heap
{
int poz, val;
bool operator <(const heap &a) const{
if(val==a.val)
return poz<a.poz;
else
return val<a.val;
}
};
set <heap> h;
int v[NMAX+5];
int main()
{
int n, i, k, t, x;
fin>>n;
k=0;
heap a;
for(i=1;i<=n;i++)
{
fin>>t;
if(t==1)
{
fin>>x;
k++;
a.poz=k;
a.val=x;
v[k]=x;
h.insert(a);
}
else
{
if(t==2)
{
fin>>x;
a.poz=x;
a.val=v[x];
h.erase(a);
}
else
{
fout<<(*h.begin()).val<<"\n";
}
}
}
return 0;
}