Pagini recente » Cod sursa (job #1973557) | Cod sursa (job #2342006) | Cod sursa (job #2913916) | Cod sursa (job #39471) | Cod sursa (job #3252654)
#include <iostream>
#include <fstream>
#include <set>
#define Nmax 200010
using namespace std;
ifstream fin("heapuri.in");
ofstream fout("heapuri.out");
set<int> s;
int n , cod , aparitii[Nmax] , x , nr;
/*
int n,nr,lung,cod,x,position;
int H[Nmax],ord[Nmax],poz[Nmax];
void push_top(int x)
{
while(x/2 && H[x]<H[x/2])
{
swap(H[x],H[x/2]);
poz[H[x]]=x;
poz[H[x/2]]=x/2;
}
}
void push_down(int x ,int n)
{
while(2*x<=n)
{
int p=2*x;
if(p && H[p+1]<H[p])
p++;
if(H[x]<H[p])
return;
else
{
swap(H[x],H[p]);
poz[H[x]]=x;
poz[H[p]]=p;
x=p;
//cout<<" ... " <<H[x]<< " " << H[p]<<endl;
}
}
}
void pop(int x,int &n)
{
H[x]=H[n];
n--;
if(x>1 && H[x]<H[x/2])
push_top(x);
else{
//cout<<" " << x << " nigga " << endl;
push_down(x,n);
}
}
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
//for(int j=1;j<=lung;j++)
//cout<<H[j]<<" ";
//cout<<endl;
fin>>cod;
if(cod==1)
{
fin>>x;
nr++ , lung++;
ord[nr]=x;
H[lung]=x;
push_top(lung);
if(nr==1)
poz[x]=1;
}
else
if(cod==2)
{
fin>>position;
pop(poz[ord[position]],lung);
//cout<<poz[ord[position]]<< " = ord"<<endl;
}
else
fout<<H[1]<<'\n';
}
return 0;
}
*/
int main()
{
fin>>n;
for(int i=1;i<=n;i++)
{
fin>>cod;
if(cod==1)
{
fin>>x;
aparitii[++nr]=x;
s.insert(x);
}
else if(cod==2)
{
fin>>x;
s.erase(aparitii[x]);
}
else
{
fout<< *s.begin()<<'\n';
}
}
}