HDU 4006优先队列
//按照降序排列,而且队列中只保存k个元素 #include<stdio.h> #include<queue>
using namespace std; int main(){
int n,k;
while(~scanf("%d%d",&n,&k)){
priority_queue<int,vector<int>,greater<int> > q;
for(int i=;i<n;i++){
char c[];
scanf("%s",c);
if(c[]=='I'){
int a;
scanf("%d",&a);
q.push(a);
if(q.size()>k){
q.pop();
}
}
else{
printf("%d\n",q.top());
}
}
}
}
HDU 4006优先队列的更多相关文章
- HDU 4006 优先队列
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- hdu 4006 优先队列 2011大连赛区网络赛F **
签到题都要想一会 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ...
- hdu 4006 The kth great number (优先队列)
/********************************************************** 题目: The kth great number(HDU 4006) 链接: h ...
- hdu 4006 The kth great number(优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006 题目大意: 第一行 输入 n k,后有 n 行,对于每一行有两种状态 ,①“I x” : 插入 ...
- HDU 4006 The kth great number(multiset(或者)优先队列)
题目 询问第K大的数 //这是我最初的想法,用multiset,AC了——好吧,也许是数据弱也有可能 //multiset运用——不去重,边插入边排序 //iterator的运用,插入的时候,如果是相 ...
- HDU 4006 The kth great number【优先队列】
题意:输入n行,k,如果一行以I开头,那么插入x,如果以Q开头,则输出第k大的数 用优先队列来做,将队列的大小维护在k这么大,然后每次取队首元素就可以了 另外这个维护队列只有k个元素的时候需要注意一下 ...
- HDU 4006 The kth great number 优先队列、平衡树模板题(SBT)
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- HDU 4006 The kth great number (优先队列)
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- hdu 4006 第K大的数(优先队列)
N次操作 I是插入一个数 Q是输出第K大的数 Sample Input8 3 //n kI 1I 2I 3QI 5QI 4Q Sample Output123 # include <iostre ...
随机推荐
- Python学习day04 - Python基础(2)数据类型基础
<!doctype html>day04 - 博客 figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { ...
- 阿里云服务器(一)——Nodejs环境配置
最近在阿里云上买了一个轻量应用服务器,想着用来学习一下Nodejs. 64位 配置Nodejs环境: 参考:https://www.runoob.com/nodejs/nodejs-install-s ...
- MapReduce 图解流程
Anatomy of a MapReduce Job In MapReduce, a YARN application is called a Job. The implementation of t ...
- Autoware显示用户界面细节
https://blog.csdn.net/jianxuezixuan/article/details/86015224
- 微信小程序多商品评价评星提交
<form bindsubmit="submitComment"> <block wx:for="{{commentList}}" wx:ke ...
- 工控安全入门(六)——逆向角度看Vxworks
上一篇文章中我们对于固件进行了简单的分析,这一篇我们将会补充一些Vxworks的知识,同时继续升入研究固件内容. 由于涉及到操作系统的内容,建议大家在阅读本篇前有一定操作系统知识的基础,或者是阅读我的 ...
- Delphi 设计模式:《HeadFirst设计模式》Delphi7代码---观察者模式之WeatherReport[转]
1 2{<HeadFirst设计模式>之观察者模式 } 3{ 主题与观察者 } 4{ 编译工具 :Delphi7.0 ...
- XSS“从1到0”
时隔半年终于也应该更新了,之前说的每周更新也因为懒散这个借口变得遥遥无期.之所以叫这个标题,是在Freebuf上看到一篇文章,开头作者问到:“网上大多的文章标题都是XXX从0开始,可我们到底什么时候能 ...
- PAT甲级——A1036 Boys vs Girls
This time you are asked to tell the difference between the lowest grade of all the male students and ...
- csdn vip文章:Unity游戏开发-小游戏-非常简单的游戏-unity-
原文https://blog.csdn.net/qq_20484877/article/details/81841190 1*创建物体 Create菜单下 3D Object菜单下Cube 1.1设置 ...