Pagini recente » Istoria paginii runda/vvvvvv/clasament | Cod sursa (job #1928162) | Cod sursa (job #2177917) | Cod sursa (job #967756) | Cod sursa (job #392763)
Cod sursa(job #392763)
#include <algorithm>
#include <bitset>
#include <queue>
using namespace std;
#define mp make_pair
#define DIM 200005
#define sc second
#define fs first
bitset <DIM> d;
int n,in;
struct cmp
{
bool operator () (const pair <int,int> &a,const pair <int,int> &b) const
{
return a.fs>b.fs;
}
}; priority_queue <pair <int,int>, vector <pair <int,int> >,cmp> q;
int main ()
{
freopen ("heapuri.in","r",stdin);
freopen ("heapuri.out","w",stdout);
int i,tip,x;
scanf ("%d",&n);
for (i=1; i<=n; ++i)
{
scanf ("%d",&tip);
if (tip==1)
{
scanf ("%d",&x);
q.push (mp (x,++in));
}
else if (tip==2)
{
scanf ("%d",&x);
d[x]=1;
}
else
{
for ( ; d[q.top ().sc]; q.pop ());
printf ("%d\n",q.top ().fs);
}
}
}