HDOJ4006 The kth great number 【串的更改和维护】
The kth great number
Total Submission(s): 6121 Accepted Submission(s): 2471
I 1
I 2
I 3
Q
I 5
Q
I 4
Q
2
3
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).
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int b[];
int main(){
int i,j,t,n,k,num,flag_t,min,flag;
char c;
while(EOF != scanf("%d%d",&n,&k)){
flag_t = ;
min = ;
while(n--){
getchar();
scanf("%c",&c);
if(c == 'I'){
scanf("%d",&num);
if(flag_t < k){
b[flag_t] = num;
if(num < min){
min = num;
flag = flag_t;
}
flag_t++;
}
else if(num > min){
b[flag] = num;
min = ;
for(i=;i<k;i++){
if(b[i] < min){
min = b[i];
flag = i;
}
}
}
}
else if(c == 'Q'){
printf("%d\n",min);
}
}
}
return ;
}
HDOJ4006 The kth great number 【串的更改和维护】的更多相关文章
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- [LintCode] Kth Smallest Number in Sorted Matrix 有序矩阵中第K小的数字
Find the kth smallest number in at row and column sorted matrix. Have you met this question in a rea ...
- hdu 4006 The kth great number (优先队列)
/********************************************************** 题目: The kth great number(HDU 4006) 链接: h ...
- Lintcode: Kth Smallest Number in Sorted Matrix
Find the kth smallest number in at row and column sorted matrix. Example Given k = 4 and a matrix: [ ...
- hdoj 4006 The kth great number【优先队列】
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- The kth great number(set)
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Oth ...
- 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 优先队列、平衡树模板题(SBT)
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 ...
随机推荐
- Windows Server 2012 安装dll到GAC
使用Windows管理员打开PowerShell: 运行以下命令: Set-location "c:\tools\gac" [System.Reflection.Assembly] ...
- 浅谈PHP技术应用
序号:1210-41 黑龙江省高等教育自学考试 本科毕业论文 题 目 浅谈PHP技术 学员姓名 夏滟 专 业 计算机及应用 准考证号 010311192585 指导 ...
- js和jQuery写简单下拉菜单
1.jQuery写法 <head> <meta http-equiv="Content-Type" content="text/html; charse ...
- BlokUI的使用
1.点击弹出层以外的区域关闭弹出层 $(document).ready(function() { $('#demo9').click(function() { $.blockU ...
- gets scanf以及缓冲区域的问题
1:scanf scanf会忽略开头所有的空格,并以Space Enter Tab 结束输入, 不会舍弃最后的回车符(即回车符会残存在缓冲区域中) 2:getchar getchar以Enter结束, ...
- 基础算法-查找:线性索引查找(I)
前面介绍的几种查找的算法都是基于数据有序的基础上进行的.但是在实际的应用中,很多数据集可能有惊人的数据量,面对这些海量的数据,要保证记录全部按照当中的某个关键字有序,其时间代价是非常昂贵的,所以这种数 ...
- 关于Ubuntu远程ssh连接失败的问题
在做机器人项目的时候,用的是Ubuntu的linux,跟之前的CentOS的操作命令有一点差别,就比如防火墙的名字,在Ubuntu系统中叫什么ufw,真是有点不好接受. 为了能模拟环境,我又弄了一台电 ...
- octopress command memo
1 rake new_post rake new_post[title] # Begin a new post in source/_posts 2 rake preview ht ...
- 谈谈我的iOS学习及分享
iOS可以说是最近几年比较热门和高速发展一个系统,因此iOS开发也变得火热.越来越多的程序员都转向了iOS开发,每个人的学习方法都不同,分享下我的学习经历和见解吧.我之前学习过C++和Qt,Java也 ...
- elk工作原理
这个配置文件,是读取nginx日志写入到redis zjtest7-redis:/usr/local/logstash-2.3.4/config# cat logstash_agent.conf in ...