HDU 4006 优先队列
The kth great number
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 10390    Accepted Submission(s): 4153
Ming and Xiao Bao are playing a simple Numbers game. In a
round Xiao Ming can choose to write down a number, or ask
Xiao Bao what the kth great number is. Because the number
written by Xiao Ming is too much, Xiao Bao is feeling giddy. Now, try to
help Xiao Bao.
are several test cases. For each test case, the first line of input
contains two positive integer n, k. Then n lines follow. If Xiao Ming
choose to write down a number, there will be an " I" followed by a
number that Xiao Ming will write down. If Xiao Ming choose to ask Xiao
Bao, there will be a "Q", then you need to output the kth great number.
Xiao Ming won't ask Xiao Bao the kth great number when the number of the written number is smaller than k. (1=<k<=n<=1000000).
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<functional>
#include<vector>
using namespace std;
int n,k;
int main()
{
char ch[];
int x;
while(scanf("%d%d",&n,&k)!=EOF)
{
priority_queue<int,vector<int>,greater<int> >que;
while(n--)
{
scanf("%s",ch);
if(ch[]=='I')
{
scanf("%d",&x);
que.push(x);
}
else
{
printf("%d\n",que.top());
}
if(que.size()>k)
que.pop();
}
}
return ;
}
HDU 4006 优先队列的更多相关文章
- hdu 4006 优先队列 2011大连赛区网络赛F **
		签到题都要想一会 #include<cstdio> #include<iostream> #include<algorithm> #include<cstri ... 
- HDU 4006优先队列
		//按照降序排列,而且队列中只保存k个元素 #include<stdio.h> #include<queue> using namespace std; int main(){ ... 
- 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 ... 
随机推荐
- 在苹果手机上input有内阴影怎么去除
			一个input中在安卓手机上完全按照自己的样式去展示,但是在苹果手机上发现Input有内阴影,怎么去除内阴影呢? 在input样式中这样添加 #div{ .... appearance:button; ... 
- java 请求 google translate
			// */ // ]]> java 请求 google translate Table of Contents 1. 使用Java获取Google Translate结果 1.1. 开发环境设置 ... 
- SQLServer 表结构相关查询(快速了解数据库)
			-- 表结构查询 SELECT 表名 then d.name else '' end, 表说明 then isnull(f.value,'') else '' end, 字段序号 = a.colord ... 
- 使用J2SE API读取Properties文件的六种方法
			1.使用java.util.Properties类的load()方法示例: InputStream in = lnew BufferedInputStream(new FileInputStream( ... 
- a与a:link、a:visited、a:hover、a:active
			原文地址http://www.cnblogs.com/exmyth/p/3226654.html a与a:link.a:visited.a:hover.a:active 起因: a与a:link的 ... 
- css整理-05 边框,背景和浮动,定位
			边框 样式:border-style hidden, dotted, dashed, solid , double, groove, ridge, inset, outset 最不可预测的是doubl ... 
- Poj1131-Octal Fractions
			Octal Fractions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6669 Accepted: 3641 D ... 
- 【原】iOS学习之卸载Openfire
			在即时通信编程中,你的Openfire服务可能因为各种不同的原因,出现不能使用.无法连接等问题. 解决这类问题最直接和省时间的方式就是卸载后重装,本篇主要为大家介绍如何卸载Openfire. 首先,确 ... 
- XIII Open Cup named after E.V. Pankratiev. GP of America
			A. Explosions 注意到将炸弹按坐标排序后,每个炸弹直接引爆和间接引爆的都是连续的一段区间,因此只需要求出每个炸弹能间接炸到的最左和最右的炸弹即可. 建立图论模型,炸弹$i$向炸弹$j$连单 ... 
- CDOJ 1431 不是图论 Label:Tarjan || Kosarajn
			Time Limit:1000MS Memory Limit:65535KB 64bit IO Format:%lld & %llu Description 给出一个nn个点, ... 
