HDU 4006

#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
struct cmp
{
    bool operator()(int x, int y)
    {
        return x > y;
    }
};
priority_queue<int, vector<int>, cmp>q;
int main(int argc, char const *argv[]) 
{
    int n, k, temp;
    char str[2];
    //freopen("in.c", "r", stdin);
    while(~scanf("%d%d", &n, &k))
    {
        while(!q.empty())
            q.pop();
        for(int i = 0;i < n;i ++)
        {
            scanf("%s", str);
            if(str[0] == 'I')
            {
                scanf("%d", &temp);
                q.push(temp);
                if(q.size() > k)
                    q.pop();
            }
            else
                printf("%d\n", q.top());
        }
    }
    return 0;
}


posted on 2014-04-30 18:37  wangzhili  阅读(88)  评论(0编辑  收藏  举报