用STL建堆做的,76分求助
查看原帖
用STL建堆做的,76分求助
169756
zcayyds楼主2022/10/15 20:13
#include<bits/stdc++.h>
using namespace std;
int n,tot,op;
vector <int>num;
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>op;
if(op==1){
cin>>tot;
num.push_back(tot);
make_heap(num.begin(),num.end(),greater<int>());
}
if(op==2){
cout<<num[0]<<endl;
}
if(op==3){
pop_heap(num.begin(),num.end(),greater<int>());
num.pop_back();
}
}
return 0;
}

原谅我没有缩进,要不然放不下

2022/10/15 20:13
加载中...