题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006

思路:利用优先队列的性质,将数据存入后会自动对数据进行排序

 #include<stdlib.h>
#include<time.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std; int main()
{
int n,k,a;
string str;
while(scanf("%d %d",&n,&k)!=EOF)
{
priority_queue<int,vector<int>,greater<int> > q;
while(n--)
{
cin>>str;
if(str.at() == 'I')
{
scanf("%d",&a);
q.push(a);
if(q.size()>k)
q.pop();
}
else
cout<<q.top()<<endl;
}
}
return ;
}

hdu 4006 The kth great number的更多相关文章

  1. hdu 4006 The kth great number (优先队列)

    /********************************************************** 题目: The kth great number(HDU 4006) 链接: h ...

  2. 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 ...

  3. HDU 4006 The kth great number (优先队列)

    The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Oth ...

  4. HDU - 4006 The kth great number multiset应用(找第k大值)

    The kth great number Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming ...

  5. hdu 4006 The kth great number(优先队列)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006 题目大意: 第一行 输入 n k,后有 n 行,对于每一行有两种状态 ,①“I x” : 插入 ...

  6. HDU 4006 The kth great number(multiset(或者)优先队列)

    题目 询问第K大的数 //这是我最初的想法,用multiset,AC了——好吧,也许是数据弱也有可能 //multiset运用——不去重,边插入边排序 //iterator的运用,插入的时候,如果是相 ...

  7. HDU 4006 The kth great number【优先队列】

    题意:输入n行,k,如果一行以I开头,那么插入x,如果以Q开头,则输出第k大的数 用优先队列来做,将队列的大小维护在k这么大,然后每次取队首元素就可以了 另外这个维护队列只有k个元素的时候需要注意一下 ...

  8. HDU 4006 The kth great number AVL解

    提供动态更新数据.第实时QK大量的值什么? 使用AVL统计数据结构做,比较先进的数据结构的内容. 不知道给出的数据为准值是否有反复.下面的程序是因为我能够处理重复数据出现的情况下,. 了repeat的 ...

  9. hdoj 4006 The kth great number【优先队列】

    The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Oth ...

随机推荐

  1. 字串符相关 split() 字串符分隔 substring() 提取字符串 substr()提取指定数目的字符 parseInt() 函数可解析一个字符串,并返回一个整数。

    split() 方法将字符串分割为字符串数组,并返回此数组. stringObject.split(separator,limit) 我们将按照不同的方式来分割字符串: 使用指定符号分割字符串,代码如 ...

  2. 2016移动端web5分钟速成(适合新手)

    http://www.w3cfuns.com/notes/20813/fecbb840a2574cf712a8625f88a7ab3a.html

  3. ACM - a + b Problem

    前几天看了ACM的第一题,映入眼帘的是一个“简单”的题目: 输入两个数,a,b 输出他们的和. 本着,此乃ACM的原则,便有了如下的思考: ACM的题目肯定很难,a+b,怎么可能直接printf,不行 ...

  4. [翻译]opengl扩展教程2

    [翻译]opengl扩展教程2 原文地址https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/extensions_part2.php [ ...

  5. 转: Annovar 软件注释流程介绍

    第一步:下载Annovar 上Annovar官网下载(http://annovar.openbioinformatics.org/en/latest/user-guide/download/),现在要 ...

  6. SQL Sever2008r2 数据库服务各种无法启动的解决办法

    一.Sql Server服务远程过程调用失败解决 以前出现过这个问题,那时候是因为把实例安装在了D盘,后来D盘被格式化了.然后,这些就没了.今天早上打开电脑,竟然又出现这个问题,可是Server200 ...

  7. [ruby on rails] 深入(1) ROR的一次request的响应过程

    示意图 即: 1.  浏览器发起请求 2. Routes对请求进行一个url映射,交给对应的Controller来处理 3/4. Contoller从Model中获取数据(或者操作数据) 5. 返回给 ...

  8. poj 1182

    http://poj.org/problem?id=1182 一个利用并查集的经典题目. 思路:在网上看到别人的思路,觉得方法还是挺不错的. 首先,开辟一个3*n的数组belg,用来存b和c的关系,在 ...

  9. hdu2457

    AC自动机+DP #include <cstdio> #include <queue> #include <cstring> using namespace std ...

  10. iOS 串行网络请求。。。待研究

    nsurlsession 和 nsurlconnection 能实现吗? 手动实现的关键点在哪里? 我这里说的串行网络请求,指的是第一个网络请求不返回数据,第二个网络请求就不能开始. AFNetwor ...