HDU Problem 4006 The kth great number 【队列】
来源:互联网 发布:pdf格式软件下载 编辑:程序博客网 时间:2024/05/24 01:41
The kth great number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 10020 Accepted Submission(s): 3997
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 3I 1I 2I 3QI 5QI 4Q
Sample Output
123HintXiao 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
The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest
Recommend
lcy | We have carefully selected several similar problems for you: 4003 4007 4008 4005 4001
#include <cmath>#include <queue>#include <stack>#include <cstdio>#include <cstring>#include <algorithm>#define MAX_N 1005using namespace std;const int INF = 0xffff;struct node{ int x; friend bool operator < (node a, node b) { return a.x > b.x; }}temp;int main() { int n, t, a; char s[7]; while (scanf("%d%d", &n, &t) != EOF) { priority_queue<node> que; while (n--) { scanf("%s", s); if (s[0] == 'I') { scanf("%d", &a); temp.x = a; que.push(temp); while (que.size() > t) que.pop(); } else { printf("%d\n", que.top().x); } } } return 0;}
0 0
- HDU Problem 4006 The kth great number 【队列】
- HDU 4006 The kth great number 【队列】
- hdu 4006 The kth great number(使用优先队列)
- hdu 4006 The kth great number 优先级队列
- HDU 4006 The kth great number(优先队列、堆实现)
- HDU 4006 The kth great number (堆实现优先队列)
- HDU 4006 The kth great number(优先队列)
- HDU 4006 The kth great number(优先队列)
- hdu 4006 The kth great number(优先队列)
- hdu 4006 The kth great number 优先队列
- HDU-#4006 The kth great number(优先队列)
- HDU 4006 The kth great number【优先队列】
- hdu 4006 The kth great number(优先队列)
- HDU 4006 The kth great number(优先队列)
- hdu杭电4006 The kth great number【优先队列】
- hdu 4006 The kth great number(线段树 || 优先队列)
- HDU 4006 The kth great number(优先队列)
- HDU 4006 The kth great number (优先队列)
- UVA 10655 Contemplation! Algebra(构造矩阵)
- ubuntu 开启自启动配置
- VBA操作提取出sql
- Android Studio 一些快捷键
- c/c++ 位运算符
- HDU Problem 4006 The kth great number 【队列】
- 【GRYZ2015】足球联赛
- 【HDU】1042 - N!(java - BigDecimal)
- JAVA-GetDay
- maven常用镜像
- 【技术贴】ArcGIS Runtime Esri新的离线地图数据格式——移动地图包
- iOS 第三方框架 - CocoaPods的安装、使用、原理
- STM32串口1发送,串口2接收
- 线性表的基本操作:插入、删除、查找等操作在顺序存储结构和链接存储结构上的算法及其实现方法。 2006-05-05 10:32:58