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. double类型如何保留2为小数

    double d=12.2121;string str = d.ToString("F2"); double x = 29.982;Console.WriteLine(x.ToSt ...

  2. 转:SVN 出现This client is too old to work with working copy...错误

    本地进行SVN客户端版本更新,但是之前一些代码是用的旧svn客户端提交的,这时候进行代码更新或者提交代码可能会出现错误,我这边是NetBeans中提交代码就出现了以下错误:This client is ...

  3. 地址重写--Java中urlrewriter的使用

    最近公司以前的一个项目需要升级改版,其中的一个模块是使用Struts2做的不需要改动,但是需要将其从之前的项目里面剥离出来,看了看官网,发现所有的链接访问的静态地址,以为是FreeMarker实现的, ...

  4. REST API初识及设计

    网络应用程序,分为前端和后端两个部分.当前的发展趋势,就是前端设备层出不穷(手机.平板.桌面电脑.其他专用设备......). 因此,必须有一种统一的机制,方便不同的前端设备与后端进行通信.这导致AP ...

  5. 第01讲- Android背景知识

    第01讲Android背景知识 Android是基于Linux系统 Android系统框图 : 第一.操作系统层(OS) 第二.各种库(Libraries)和Android 运行环境(RunTime) ...

  6. VMware+Ubuntu8.10+Skyeye+gdb实现u-boot源码调试

    系统平台:WindowsXP 虚拟机: VMware Workstation 6.5.0 Ubuntu8.10 安装程序 ubuntu-8.10-desktop-i386.iso 下载地址:http: ...

  7. Oracle 方法

    1.递归 select zxdept from (select d.id, d.zxdept, d.RANK, d.fatherId from web_dept d start with d.id = ...

  8. request.getRequestURI()与request.getRequestURL()

    request.getRequestURL() 获得 http://www.quanqiuyouhui.com/ds-api-test/authorization/test.do request.ge ...

  9. input输入字母自动大小写转换

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  10. 【jquery ,ajax,php】加载更多实例

    jquery $(function() { //初始化 getData(0); var index = 1; $("#more").click(function() { getDa ...