题目链接
题意:
初始小根堆为空,我们需要支持以下3种操作: 操作1: 1 x 表示将x插入到堆中 操作2: 2 输出该小根堆内的最小数 操作3: 3 删除该小根堆内的最小数
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std
;
int n
,ask
,a
;
priority_queue
<int,vector
<int>,greater
<int> > q
;
int main()
{
cin
>>n
;
while(n
--)
{
cin
>>ask
;
if(ask
==1)
{
cin
>>a
; q
.push(a
);
}
if(ask
==2) cout
<<q
.top()<<endl
;
if(ask
==3) q
.pop();
}
}
转载请注明原文地址: https://www.6miu.com/read-5033645.html