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. PHP-FPM小故障解决记录

    前天昨天发生的事. 阿里云升级MYSQL,申请只读库之后,IP发生了改变,PHP中关于数据库的连接都需要修改. 我们是以实例名作为统一连接字符的. 但在其中一台后端机器上,死活不生效. 就是如何是用I ...

  2. 如何向投资人展示——How to Present to Investors

    著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:茶叶末链接:http://www.zhihu.com/question/23638879/answer/34525204来源: ...

  3. 【温故而知新:文件操作】C#的文件读写相关

    StreamReader类以及其方法ReadLine,Read,ReadToEnd的分析 首先StreamReader类的构造参数非常丰富在这里,我觉得最常用的就是StreamReader(Strea ...

  4. Linux kernel API的查看

    一般来说Linux上查看一些函数API的说明咱们可以man一下.man 2是syscall,man 3是一些库的函数API. 以下是man sections的一些说明 The table below ...

  5. CF 584B Kolya and Tanya

    题目大意:3n个人围着一张桌子,给每个人发钱,可以使1块.2块.3块,第i个人的金额为Ai.若存在第个人使得Ai + Ai+n + Ai+2n != 6,则该分配方案满足条件,求所有的满足条件的方案数 ...

  6. mips平台使用jdbc操作sqlite的最终解决方案

    1.概述: 本项目需要在多平台上(mips必须支持)操作嵌入式数据库sqlite,而最新的sqlite-jdbc-3.15.1.jar的本地驱动只含有少量的平台,于是解决支持mips平台实在必行.方法 ...

  7. hdu 3853 LOOPS(概率 dp 期望)

    Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help ...

  8. IOS 用drawRect 画表格

    自定义一个View DrawLine DrawLine.h #import <UIKit/UIKit.h> @protocol gridTouchDelete <NSObject&g ...

  9. sql注入数据库修复方法

    1.第一种情况是 需要将指定的 注入字符串全部替换掉(仅替换注入的字符串为空) declare @delStr nvarchar(500) set @delStr='<script src=ht ...

  10. iOS8 Core Image In Swift:更复杂的滤镜

    iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...