hdu 4006 The kth great number (优先队列)

时间:2023-01-23 12:14:45
 /**********************************************************
题目: The kth great number(HDU 4006)
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4006
算法: 优先队列
************************************************************/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<queue>
#include<vector>
using namespace std; priority_queue <int, vector<int>,greater<int> > que; int main()
{
int n,k;
while (~scanf("%d%d",&n,&k))
{
while (!que.empty()) que.pop();
char c;
int x;
while (n--)
{
scanf(" %c",&c);
if (c=='I')
{
scanf("%d",&x);
que.push(x);
while (que.size()>k) que.pop();
}
else printf("%d\n",que.top());
}
}
}