码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 4006 优先队列 2011大连赛区网络赛F **

时间:2015-07-28 00:33:35      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:

签到题都要想一会

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<algorithm>
 4 #include<cstring>
 5 #include<cmath>
 6 #include<queue>
 7 #include<map>
 8 using namespace std;
 9 #define MOD 1000000007
10 const int INF=0x3f3f3f3f;
11 const double eps=1e-5;
12 typedef long long ll;
13 #define cl(a) memset(a,0,sizeof(a))
14 #define ts printf("*****\n");
15 const int MAXN=1005;
16 int n,m,tt;
17 priority_queue<int,vector<int>,greater<int> > q;
18 int main()
19 {
20     int i,j,k;
21     #ifndef ONLINE_JUDGE
22     freopen("1.in","r",stdin);
23     #endif
24     char s[10];
25     while(~scanf("%d%d",&m,&k))
26     {
27         int x;
28         while(!q.empty())    q.pop();
29         for(i=0;i<m;i++)
30         {
31             scanf("%s",s);
32             if(s[0]==I)
33             {
34                 scanf("%d",&x);
35                 if(q.size()<k)  q.push(x);
36                 else if(q.top()<x)
37                 {
38                     q.pop();
39                     q.push(x);
40                 }
41             }
42             else printf("%d\n",q.top());
43         }
44     }
45 }

 

hdu 4006 优先队列 2011大连赛区网络赛F **

标签:

原文地址:http://www.cnblogs.com/cnblogs321114287/p/4681504.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!