The kth great number(优先队列)
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
I 1
I 2
I 3
Q
I 5
Q
I 4
Q
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(优先队列)的更多相关文章
- hdu 4006 The kth great number (优先队列)
/********************************************************** 题目: The kth great number(HDU 4006) 链接: h ...
- 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 ...
- 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 ...
- hdu 4006 The kth great number(优先队列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006 题目大意: 第一行 输入 n k,后有 n 行,对于每一行有两种状态 ,①“I x” : 插入 ...
- hdoj 4006 The kth great number【优先队列】
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- HDU 4006 The kth great number (优先队列)
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDOJ4006 The kth great number 【串的更改和维护】
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- [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 ...
随机推荐
- Hdu1092
#include <stdio.h> int main() { ; while(scanf("%d",&n)){ ) {;} else{ int i,a; ;i ...
- 树莓派 wheezy安装与远程登录配置
一.准备工作 1:wheezy系统镜像 2:Win32DiskImager-0.9.5-install 3:SDFormatter 4:SD卡 我用的是8G 二.安装系统 流程:SDFormatter ...
- 关于Fragment与Activity的想法
View,Fragment,Activity,ListView等都会涉及到Layout文件 不要从Layout来考虑,而是从Activity,Fragment,来考虑,Layout只是他们的一个属性 ...
- Codeforces 366C Dima and Salad
http://codeforces.com/problemset/problem/366/C 题意:在一个冰箱里有n种水果,并且这些水果每一种都有一个美味度和一个卡路里的属性, 小明要从这些水果中选出 ...
- Android中ListView嵌套GridView的简单消息流UI(解决宽高问题)
最近搞一个项目,需要用到类似于新浪微博的消息流,即每一项有文字.有九宫格图片,因此这就涉及到ListView或者ScrollView嵌套GridView的问题.其中GridView的高度问题在网上都很 ...
- winform程序中Label自动换行
参考的是网上这篇文章:http://www.cnblogs.com/qb371/archive/2011/09/20/2366310.html 不过貌似注释有点问题,我的代码如下,我是将label放在 ...
- 【转】Java基本数据类型
原文网址:http://blog.csdn.net/bingduanlbd/article/details/27790287 Java语言是静态类型的(statical typed),也就是说所有变量 ...
- Rainmeter 雨滴桌面 主题分享
说明 先安装主程序 Rainmeter-3.1.exe,然后安装 Techzero_1.0.rmskin,打开主题管理应用主题就可以. 下载 http://pan.baidu.com/s/1i3zI3 ...
- linux TIME_WAIT过多的解决方法
查看TCP状态:netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'查看SOCKET状态:cat /proc/n ...
- [Ember] Wraming up
1.1: <!DOCTYPE html> <html> <head> <base href='http://courseware.codeschool.com ...