题目大意:
添加和删除一个数,然后输出中位数。
简单的Splay 维护Splay上有多少个节点就可以了
#include
#include
#define inf 1LL<<60
#define maxn 222222
#define keyTree (ch[ch[root][1]][0])
using namespace std;
typedef long...
分类:
其他好文 时间:
2014-05-07 07:46:42
阅读次数:
405
29:数组中出现次数超过一半的数字 方法a. 排序取中 O(nlogn) 方法b.
partition 函数分割找中位数 >=O(n) 方法 c. 设计数变量,扫描一遍。 O(n)#include int findNumber(int
data[], unsigned length){/* if(c...
分类:
其他好文 时间:
2014-05-02 19:47:41
阅读次数:
535
29. 数组中出现次数超过一半的数字. 方法a. 排序取中 O(nlogn). 方法b.
partition 函数分割找中位数 >=O(n). 方法c. 设计数变量,扫描一遍。 O(n).#include bool Invalid_Input
= false;int getNumber(int da...
分类:
其他好文 时间:
2014-05-02 10:46:15
阅读次数:
340
2014-04-29
04:18题目:有一连串的数被读入,设计一个数据结构,能随时返回当前所有数的中位数。解法:用一个大顶堆,一个小顶堆将数分成数量最接近的两份,就能轻松得到中位数了。代码:
1 // 18.9 A stream of integers are passed to you, you....
分类:
其他好文 时间:
2014-04-29 14:16:52
阅读次数:
423