The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 8246    Accepted Submission(s): 3261 Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round…
/********************************************************** 题目: The kth great number(HDU 4006) 链接: http://acm.hdu.edu.cn/showproblem.php?pid=4006 算法: 优先队列 ************************************************************/ #include<cstdio> #include<cst…
The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) [Problem Description] Xiao  Ming  and  Xiao  Bao  are  playing  a  simple  Numbers  game.  In  a  round  Xiao  Ming  can choose  to  write  down …
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006 题目大意: 第一行 输入 n k,后有 n 行,对于每一行有两种状态 ,①“I x” : 插入 x ② “Q” : 输出当前 第 K大的数 解题思路: 利用优先队列保证插入新数据后的队列是有序的. 重点:保证 k 个数的队列就行.加一个标志 flag_k; I: 如果 flag_k<k,则将新输入的数放入队列中. 否则判断第k个数是否小于新输入的数,如果小于,则队头出队,新输入的入队:保证队列…
The kth great number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 5049    Accepted Submission(s): 2069 Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round…
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 t…
The kth great number 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 feel…
题目 询问第K大的数 //这是我最初的想法,用multiset,AC了——好吧,也许是数据弱也有可能 //multiset运用——不去重,边插入边排序 //iterator的运用,插入的时候,如果是相同的数没直接放在相同的现有的数据后面的 #include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace std; //#define IN freopen(…
题意:输入n行,k,如果一行以I开头,那么插入x,如果以Q开头,则输出第k大的数 用优先队列来做,将队列的大小维护在k这么大,然后每次取队首元素就可以了 另外这个维护队列只有k个元素的时候需要注意一下,先将输入的数都插入之后再将多余的数弹出去,这样才能保证留在队列里面的数是前k大的数 另外想到set里面的数是从小到大排列好了的,每次取第k个元素,但是超时了= = #include<iostream> #include<cstdio> #include<cstring>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4006 思路:利用优先队列的性质,将数据存入后会自动对数据进行排序 #include<stdlib.h> #include<time.h> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <ctime> #incl…