摘要: 区间第k大 1 #include 2 #include 3 #include 4 #include 5 #define MID ((l+r)>>1) 6 using namespace std; 7 8 const int N=100500; 9 10 int a[N],s[N],t[20... 阅读全文
posted @ 2014-09-16 17:44 Mr.Youyu 阅读(122) 评论(0) 推荐(0)
摘要: 求Σ|x-xi| 最小,只要求得这个区间的中位数t,然后numl*t-suml+sumr-numr*t (如果是偶数个 任意取中间一个)。求区间中位数,可以用划分树,suml 即区间内比中位数小的数的和,也可以同时求出来。 1 #include 2 #include 3 #include ... 阅读全文
posted @ 2014-09-16 16:29 Mr.Youyu 阅读(117) 评论(0) 推荐(0)
摘要: 参考资料:百度百科 1 #include 2 #include 3 #include 4 using namespace std; 5 6 #define N 100500 7 8 #define MID ((l+r)>>1) 9 int a[N],s[N],t[2... 阅读全文
posted @ 2014-09-16 16:18 Mr.Youyu 阅读(131) 评论(0) 推荐(0)