#include<bits/stdc++.h>
using namespace std;
int n;
int cnt;
int heap[1000010];
void insert(int val){
++cnt;
heap[cnt]=val;
while(heap[cnt/2]>val){
swap(heap[cnt],heap[cnt/2]);
}
}
void erase(){
heap[1]=heap[cnt];
--cnt;
int pos=1;
while(heap[pos*2]<heap[pos]){
swap(heap[pos*2],heap[pos]);
}
}
int main(){
cin>>n;
while(n--){
int op;
cin>>op;
if(op==1){
int x;
cin>>x;
insert(x);
}else if(op==2){
cout<<heap[1]<<endl;
}else{
erase();
}
}
return 0;
}
wa on #3-10
3.in
15
1 9336
1 9645
1 5524
1 1760
3
1 7777
2
1 8838
2
3
2
2
2
1 8385
2
3.out
15
1 9336
1 9645
1 5524
1 1760
3
1 7777
2
1 8838
2
3
2
2
2
1 8385
2
请帮忙改错