随笔分类 -  线段树

摘要:#include #include #include #include #include #include #include #define lson l,m,rt> 1; build(lson); build(rson); up(rt);}int A,B;void update(... 阅读全文
posted @ 2015-08-08 22:09 sola94 阅读(131) 评论(0) 推荐(0) 编辑
摘要:题意: 一共有n天 每天西瓜售价为dp[i]元 该天的西瓜能吃v[i]天 而且这天如果买了西瓜之前的西瓜就要扔掉 问每天都吃到西瓜的最小花费是多少思路: 从最后一天开始dp最小花费 并用线段树单点更新来维护#include #include #include #include using names... 阅读全文
posted @ 2015-04-15 20:42 sola94 阅读(161) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=3468题意 :对于一个序列有两种操作 1 查询 l到r 的和 2 对于l 到r上的每个数 加上 up思路: 用单点更新必然超时 所以需要区间更新(位运算时 注意 m-m>>1 与 m-(m>>1) 的区别)#include#inclu... 阅读全文
posted @ 2015-02-03 22:39 sola94 阅读(132) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1754照着hdu 1166 的模板稍加改动即可#include#include#include#includeusing namespace std;int sum[1000000];void push(int r... 阅读全文
posted @ 2015-02-02 17:05 sola94 阅读(120) 评论(0) 推荐(0) 编辑
摘要:今天终于看懂树状函数了 看懂之后果然感觉比线段树简单便捷地多就拿这题简单的单点更新来练手了#include#include#include#includeusing namespace std;int n;int a[50000+10];int c[50000+10];int lowbit(int ... 阅读全文
posted @ 2014-09-18 19:44 sola94 阅读(124) 评论(0) 推荐(0) 编辑
摘要:题意:有一块h*w 的广告牌用来贴广告 每个广告 1*w 并且优先贴于左上方 现在给出n个广告的n 问分别贴于第几行 贴不了输出 -1思路:把1-h 作为 l-r 值 套用线段树模版#include#include#include#include#include#include#i... 阅读全文
posted @ 2014-08-23 00:11 sola94 阅读(86) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1394DescriptionThe inversion number of a given number sequencea1, a2, ..., an is the number of pairs (ai, aj... 阅读全文
posted @ 2014-08-09 20:30 sola94 阅读(197) 评论(0) 推荐(0) 编辑
摘要:http://acm.fzu.edu.cn/problem.php?pid=2171Description部队中总共有N个士兵,每个士兵有各自的能力指数Xi,在一次演练中,指挥部确定了M个需要防守的地点,指挥部将选择M个士兵依次进入指定地点进行防守任务,获得的参考指数即为M个士兵的能力之和。随着时间... 阅读全文
posted @ 2014-08-09 00:05 sola94 阅读(348) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示