The kth great number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 8881    Accepted Submission(s): 3518

Problem Description
Xiao 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.
 
Input
There 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.
 
Output
The output consists of one integer representing the largest number of islands that all lie on one line.
 
Sample Input
8 3
I 1
I 2
I 3
Q
I 5
Q
I 4
Q
 
Sample Output
1
2
3
 #include <iostream>
#include <stdio.h>
#include <queue>
using namespace std;
int a[+];
struct node
{
friend bool operator< (node a,node b)
{
return a.v>b.v;
}
int v;
};
int main()
{
int n,k;
int i,j;
char ch;
freopen("in.txt","r",stdin);
while(scanf("%d%d",&n,&k)!=EOF)
{
bool flag=;
getchar();
priority_queue<node> s;
for(i=;i<n;i++)
{
scanf("%c",&ch);
if(ch=='I')
{
node a;
scanf("%d",&a.v);
getchar();
s.push(a);
if(s.size()>k)
s.pop();
}
else if(ch=='Q')
{
getchar();
printf("%d\n",s.top().v);
}
}
}
}

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. C - The kth great number 优先队列

    Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write d ...

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

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

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

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

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

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

  7. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  8. HDOJ4006 The kth great number 【串的更改和维护】

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

  9. [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

随机推荐

  1. Android Development Tools 发生checkAndLoadTargetData错误

    之前使用时没有出现任何问题的,我把D:\IDE\ADT\adt-bundle-windows-x86_64-20140321\eclipse目录下面的 eclipse.exe重名名为adt.exe并设 ...

  2. Codeforces 366C Dima and Salad

    http://codeforces.com/problemset/problem/366/C 题意:在一个冰箱里有n种水果,并且这些水果每一种都有一个美味度和一个卡路里的属性, 小明要从这些水果中选出 ...

  3. 链接一个外部lib库的时候注意事项

    1.注意这个库是Debug版还是Release版,一般windows下,约定是Debug版的库文件名会加个d. 2.注意这个库是x86还是x64版本. 3.注意生成这个lib库的是什么编译器

  4. 性能瞬间飙升!教你如何组RAID0磁盘阵列

    性能瞬间飙升!教你如何组RAID0磁盘阵列 1组建RAID0磁盘阵列之Intel篇回顶部 前言:传统硬盘由于工作原理的限制,在性能上的提升非常缓慢.而固态硬盘价格昂贵,短时间内难以被普通用户接受.因此 ...

  5. spring框架源码编译

    程序猿小菜一枚,最近从github上面下载下来一份spring各个项目的源码一份,但是弄了很长时间,因为网速和(fanqiang)的速度,希望大家不要再为这种无谓的时间花费时间,简单来说github上 ...

  6. Hdu3498-whosyourdaddy(精确覆盖模板题)

    Problem Description sevenzero liked Warcraft very much, but he haven't practiced it for several year ...

  7. ios 导航栏和旋屏

    1,状态栏(UIStatusBar) http://my.oschina.net/shede333/blog/304560 2,visibleViewController和topViewControl ...

  8. Android图形合成和显示系统---基于高通MSM8k MDP4平台

    介绍了Android SurfaceFlinger层次以下的图形合成和显示系统,主要基于高通MSM8k MDP4x平台. 做为Android Display专题.SurfaceFlinger的详细介绍 ...

  9. 数据库--PHP环境搭建

    一: 1.PHP的架构 LAMP :Linux  阿帕奇  MySQL  PHP WAMP:Linux 阿帕奇  Mysql  PHP (集成的环境搭建软件),一键搭建PHP开发环境工具 2.修改数据 ...

  10. UGUI 快捷键创建UGUI组件

      使用NGUI的时候还有xxx快捷键创建, spirte,label,button等等. 在UGUI里面的时候好像是没有快捷键的. 不知道以后多久才能有这个功能.  在家里闲无聊的时候写了一个脚本, ...