传送门
贪心。。。蒟蒻证明不会。。。
每一次找最大的即可,找出一次最大的,数列会分为左右两边,左边用stl优先队列维护,右边用树状数组维护。。
(线段树超时了。。。。)
代码
#include <queue> #include <cstdio> #include <iostream> #define N 100001 #define ls now << 1 #define rs now << 1 | 1 #define max(x, y) (p[x].a * 2 + p[x].b > p[y].a * 2 + p[y].b ? (x) : (y)) int n, last, now, ans, M[N]; std::priority_queue <int> q; struct node p[N]; inline int read() inline void add(int x, int d) inline int query(int x) int main() else printf("%d\n", ans); } return 0; }
上一篇:[luoguP1040] 加分二叉树(DP)
下一篇:倍增专题
堆 stl 线段树 树状数组 贪心









