http://acm.hdu.edu.cn/showproblem.php?pid=2665
Problem Description
Give you a sequence and ask you the kth big number of a inteval.
Input
The first line is the number of the t...
分类:
其他好文 时间:
2015-04-24 12:33:31
阅读次数:
116
优先队列,真是水的不行~
保持队列里只有K个元素即可
#include
#include
using namespace std;
priority_queue, greater >mapp;
int n,k;
string cmd;
int main()
{
while(cin>>n>>k)
{
while(mapp.size()) mapp.pop();
while(n--)
...
分类:
其他好文 时间:
2015-04-22 22:21:58
阅读次数:
105
划分树的基本功能是,对一个给定的数组,求区间[l,r]内的第k大(小)数。划分树的基本思想是分治,每次查询复杂度为O(log(n)),n是数组规模。具体原理见http://baike.baidu.com/link?url=vIUKtsKYx7byeS2KCOHUI14bt_0sdHAa9BA1Vce...
分类:
其他好文 时间:
2015-04-20 10:47:14
阅读次数:
141
划分树 1 /* 2 HDU 2665 Kth number 3 划分树 4 5 6 */ 7 8 9 #include10 #include11 #include12 #include13 using namespace std;14 15 const int MAXN=100010;1...
分类:
其他好文 时间:
2015-04-18 15:54:54
阅读次数:
130
题意 动态查询第K大的数
用小数在前优先队列维护K个数 每要插入一个数时 若这个数小于队首元素那么就不用插入了 否则队首元素出队 这个数入队 每次询问只用输出队首元素就行了
#include
#include
using namespace std;
int main()
{
int n, a, k;
char op[5];
while(~scanf("%d%...
分类:
其他好文 时间:
2015-04-14 14:45:18
阅读次数:
175
题目:
Given an index k, return the kth row
of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k)
extra space?
...
分类:
其他好文 时间:
2015-04-09 10:33:09
阅读次数:
143
题意:输入n行,k,如果一行以I开头,那么插入x,如果以Q开头,则输出第k大的数用优先队列来做,将队列的大小维护在k这么大,然后每次取队首元素就可以了另外这个维护队列只有k个元素的时候需要注意一下,先将输入的数都插入之后再将多余的数弹出去,这样才能保证留在队列里面的数是前k大的数另外想到set里面的...
分类:
其他好文 时间:
2015-04-02 20:44:58
阅读次数:
146
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use...
分类:
其他好文 时间:
2015-03-18 12:14:34
阅读次数:
155
Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7.The eligible numbers are like 3, 5, 7, 9, 15 ...ExampleIf ...
分类:
其他好文 时间:
2015-03-09 07:01:19
阅读次数:
183