摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2038 就是莫队算法; 先写了个分块,惨WA: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #in 阅读全文
posted @ 2018-06-13 22:49 Zinn 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2442 设 f[i] 为答案,则有 f[i] = max { f[j] - s[j+1] } + s[i] ; 所以用单调队列维护 f[i] - s[i+1]; 没有1A!!原因是遍历的起点不是 阅读全文
posted @ 2018-06-13 20:04 Zinn 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=3046 就是多重集组合数(分组背包优化); 从式子角度考虑:(干脆看这篇博客) https://blog.csdn.net/viphong/article/details/48110525 从意义的角度来考虑: 当 j<=a[i] 时,f[ 阅读全文
posted @ 2018-06-13 14:39 Zinn 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1588 使用双向链表! 离线做,先抽出来排个序,按排序确定每个位置的 pre 和 nxt ,然后倒序查找,找完一个就删除一个值,更改 pre 和 nxt。 代码如下: 阅读全文
posted @ 2018-06-13 08:08 Zinn 阅读(145) 评论(0) 推荐(0) 编辑