博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4006 The kth great number (优先队列)
阅读量:7035 次
发布时间:2019-06-28

本文共 1508 字,大约阅读时间需要 5 分钟。

The kth great number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)

Total Submission(s): 5049    Accepted Submission(s): 2069

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
Hint
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).
 

 

Source
 

 

Recommend
lcy
 

 

#include
#include
#include
#include
#include
#include
using namespace std;int n,k;priority_queue
,greater
>q;int main(){ //freopen("input.txt","r",stdin); char op[3]; int x; while(~scanf("%d%d",&n,&k)){ while(!q.empty()) q.pop(); for(int i=0;i
q.top()){ q.pop(); q.push(x); } } } } return 0;}

转载地址:http://vsyal.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
远程使用sudo 执行命令,慎用!
查看>>
TMD我可知道[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]神马意思了
查看>>
《飞机大战》安卓游戏开发源码(三)
查看>>
JMS - JMS应用领域 应用场景
查看>>
[转]一步一步教你做ios推送
查看>>
【整理】关于 va_copy 的兼容性问题
查看>>
Struts秘籍之起式:第1.7式:使用Ant进行构建和部署
查看>>
python字符串/元组/列表/字典互转
查看>>
Spring Boot 入门 - 进阶篇(4)- REST访问(RestTemplate)
查看>>
Yii框架数据库多数据库、主从、读写分离
查看>>
升级到 OS X Yonsemite 10.10后 Verions 崩溃
查看>>
Oracle共享池
查看>>
oracle JOB常见的执行时间
查看>>
自动补0
查看>>
Python如何批量给云主机配置安全组?
查看>>
iOS音频播放 (四):AudioFile
查看>>
Oracle 存储过程异常处理
查看>>
URL里面存在下划线导致SESSION在IE下被分隔
查看>>
自定义注册的 Windows服务 无法访问网络共享文件解决办法
查看>>