1 /**********************************************************
 2 题目:       The kth great number(HDU 4006)
 3 链接:       http://acm.hdu.edu.cn/showproblem.php?pid=4006
 4 算法:       优先队列
 5 ************************************************************/
 6 #include<cstdio>
 7 #include<cstring>
 8 #include<algorithm>
 9 #include<cstdio>
10 #include<iostream>
11 #include<queue>
12 #include<vector>
13 using namespace std;
14 
15 priority_queue <int, vector<int>,greater<int> > que;
16 
17 int main()
18 {
19     int n,k;
20     while (~scanf("%d%d",&n,&k))
21     {
22         while (!que.empty()) que.pop();
23         char c;
24         int x;
25         while (n--)
26         {
27             scanf(" %c",&c);
28             if (c=='I')
29             {
30                 scanf("%d",&x);
31                 que.push(x);
32                 while (que.size()>k) que.pop();
33             }
34             else printf("%d\n",que.top());
35         }
36     }
37 }

 

posted on 2016-08-08 20:10  pb2016  阅读(146)  评论(0编辑  收藏  举报