#include<stdio.h>
#include<queue>
using namespace std;
struct node{
friend bool operator <(const node a,const node b)
{
return a.w>b.w;
}
int w;
};
int main()
{
int n,k;
while(scanf("%d%d",&n,&k)!=EOF)
{
getchar();
priority_queue<node>q;
while(n--)
{
char ch;
ch=getchar();
if(ch=='I')
{
node num;
scanf("%d",&num.w);
getchar();
q.push(num);
if(q.size()>k)
{
q.pop();
}
}
else
{
getchar();
node num;
num=q.top();
printf("%d\n",num.w);
}
}
}
return 0;
}
HDU 4006 优先队列
最新推荐文章于 2017-07-30 14:13:43 发布