rt,代码如下
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+5;
int n,hp[M],sz;
void _push(int x)
{
hp[++sz]=x;
int i=sz;
while (i/2>=1)
{
if(hp[i]<hp[i/2])
{
swap(hp[i],hp[i/2]);
i/=2;
}
else
break;
}
}
void _pop()
{
hp[1]=hp[sz--];
int i=1;
while (i*2<=sz)
{
int j=i*2;
if(i*2+1<=sz&&hp[i*2+1]<hp[i*2])
j=i*2+1;
if(hp[j]<hp[i])
{
swap(hp[i],hp[j]);
i=j;
}
else
break;
}
}
int main()
{
scanf("%d",&n);
for(int i=1; i<=n; ++i)
{
int op;
scanf("%d",&op);
if(op==1)
{
int x;
scanf("%d",&x);
_push(x);
}
if(op==2)
printf("%d\n",hp[1]);
if(op==3)
_pop();
}
return 0;
}