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 ...
随机推荐
- 畅通工程再续--hdu1875
畅通工程再续 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- Mysqldump记录
MySql导出特定的一段记录(导出为SQL语句) mysqldump –u root -p 数据库名 表名 --where=" author like '%Joking%' " & ...
- Oracle left查询案例
)) summoney from( select t2.ano,d.dmoney from ( select t1.*,c.cno from( select a.ano,b.bno from t_a ...
- GridView 设置背景透明以及Item的点击动画
//将点击时的背景色设置为透明 gridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); 此时点击GridView的每个Item就不会出现 ...
- javascript----bug
JSON.parse(null)------------某些手机浏览器不支持.
- LeetCode_Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...
- Tk::Table
<pre name="code" class="python"># DESCRIPTION # Tk::Table is an all-perl w ...
- bzoj1379 [Baltic2001]Postman
Description 邮递员每天给N个村子的人送信,每个村子可能在某个十字路口上,或一条路的中央. 村子里的人都希望早点收到信,因此与邮递员达成一个协议:每个村子都有一个期望值Wi,如果这个村子是邮 ...
- .net 分页案例效果
; ) { pageUrl += ) + && (totalPageCount > step ...
- Palindrome Subarrays
给定输入字符串,要求判断任意子字符串是否对称. 基本思路就是DP 写出DP表达式为 dp[i][j] = dp[i + 1][j - 1] && (s[i] == s[j]) dp[i ...