很水的一道题……
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
class cmp
{
public:
bool operator()(const int &a,const int &b) const
{
return a>b;
}
};
int main()
{
int n, k, temp;
int i, j;
char c;
priority_queue<int, vector<int>, cmp> q;
while( scanf("%d %d",&n, &k)!=EOF )
{
for( i=0;i<n;i++)
{
getchar();
scanf("%c",&c);
if( c=='I')
{
scanf("%d",&temp);
q.push(temp);
if( q.size()>k )
q.pop();
}
else if( c=='Q')
{
printf("%d\n",q.top());
}
}
while( !q.empty())
q.pop();
}
}