[luoguP2672] 推销员(贪心 + 树状数组 + 优先队列)


传送门

贪心。。。蒟蒻证明不会。。。

每一次找最大的即可,找出一次最大的,数列会分为左右两边,左边用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; }

  



上一篇:[luoguP1058] 立体图(超级大模拟(¬︿??¬☆))

下一篇:[luoguP1043] 数字游戏(DP)


stl 线段树 树状数组 贪心
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图