#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int read();
struct Node{
int left,right;
int key,tir;
}t[N];
int root,tot;
int merge(int l,int r)
{
if(!l || !r) return l|r;
if(t[l].key>t[r].key) swap(l,r);
t[l].right=merge(t[l].right,r);
if(t[t[l].left].tir<t[t[l].right].tir) swap(t[t[l].left],t[t[l].right]);
t[l].tir=t[t[l].right].tir+1;
return l;
}
void insert(int x)
{
tot++; t[tot].key=x;
root=merge(root,tot);
}
void del()
{
root=merge(t[root].left,t[root].right);
}
int main()
{
int q=read();
while(q--)
{
int opt=read();
if(opt==1)
{
int x=read();
insert(x);
}
if(opt==2) printf("%d\n",t[root].key);
if(opt==3) del();
}
return 0;
}
int read()
{
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0' && ch<='9')
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x*f;
}
代码如上,但是28pts