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 ...
随机推荐
- HDU1325 &&poj1308 基础并查集
和上一道小希的迷宫差点儿相同,可是在HDU上提交一直WA,POJ过了 HDU的数据太强了吧,强的我感觉数据有问题 题意:输入若干对点,推断是否是一颗树,转化过来也就是是否存在环 点数-边数=1,还要推 ...
- HTTP学习笔记--HTTP报文
报文流 HTTP报文在客户端.服务器和代理之间流动.“流入”.“流出”.“上游”.“下游”这些术语用来描述报文方向. 报文流入源端服务器 流入:流向服务器 流出:流向用户Age ...
- 下载文件夹里面的所有文件,并压缩成.zip压缩包的形式
http://www.aspsnippets.com/Articles/Download-multiple-files-as-Zip-Archive-File-in-ASPNet-using-C-an ...
- ADO.NET(一) 空间 ADO.NET结构 命名空间(车延禄) System.Data—— 所有的一般数据访问类 S(转载)
ADO.NET(一) 空间 ADO.NET结构 命名空间(车延禄)System.Data—— 所有的一般数据访问类System.Data.Common—— 各个数据提供程序共享(或重写)的类Sys ...
- CodeFirst-Section1之小例子
尽可能做到不说一些晦涩难懂的语言,Follow Me...... 环境:Visual Studio 2013+.Net Framework 4.5 1.什么是Code First? 说白了就是先建好C ...
- C#中析构函数,命名空间及字符串的运用(Ninth day)
又到了总结知识的时间了,今天在云和学院学习了析构函数,命名空间及字符串的处理,现在就为大家总结下来. 理论: 析构函数 不能在结构中定义析构函数.只能对类使用析构函数. 一个类只能有一个析构函数. 无 ...
- stack smashing detect错误修正
运行./a.out程序时候出现如下: *** stack smashing detected ***: ./a.out terminated段错误 (核心已转储) 一般这个错误是由于堆栈错误,很可能是 ...
- 我的Python成长之路---第六天---Python基础(20)---2016年2月20日(晴)
一.面向对象基础 面向对象名词解释: 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公 ...
- poj 2309
http://poj.org/problem?id=2309//找规律 可以看到每个根节点都可以将其在同一层的最左边的根节点整除,并且最大值为该节点加上最左边的节点值-1,最小值为////为该节点减去 ...
- clear伪类使用
都知道float会脱离文档流 用什么办法撑开父元素呢? 手动在本区块的所有float元素之后加上一个块元素并对其添加clear:both 可以 但是这样还要再去修改html页面 而且多了一个仅仅是 ...