#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
//#include<set>
//#include<bits/stdc++.h>
using namespace std;
int n,x,r;
int t=0;
int hp[1000005];
void pus(int x) {
int now=++t;
int tp=now/2;
hp[now]=x;
while(now>1) {
int tp=now/2;
if(hp[now]<hp[tp]) {
swap(hp[now],hp[tp]);
now=tp;
} else break;
}
}
void del() {
hp[1]=hp[t];
t--;
int now=1;
while(2*now<=t) {
int tp=2*now;
if(hp[tp]>hp[tp+1]&&tp<t)tp++;
if(hp[tp]<hp[now]) {
std::swap(hp[tp],hp[now]);
now=tp;
} else break;
}
}
int main() {
std::cin>>n;
for(register int i=1; i<=n; i++) {
std::cin>>r;
if(r==1) {
std::cin>>x;
pus(x);
} else if(r==2) {
std::cout<<hp[1]<<endl;
} else if(r==3) {
del();
}
}
}
就这吧。。。懒得写了。。代码应该比较明了了