POJ 3017 Cut the Sequence】的更多相关文章

Cut the Sequence \(solution:\) 这道题出的真的很好,奈何数据水啊! 这道题当时看得一脸懵逼,说二分也不像二分,说贪心也不像贪心,说搜索吧这题数据范围怎么这么大?而且这题看起来也实在不好DP,当时是真的满头雾水.只能说是各个都尝试一下.最后还是选了DP来做第一步突破,因为这道题可以用最优子结构来推出最优答案,也符合常规DP套路即设 \(F[i][j]\) 表示将前面 $ i $ 个数分成 $ j $ 份,但是这一道题没有说具体的份数,而且数据范围很大,所以我们直接设…
题目链接:http://poj.org/problem?id=3017 题意:给你一个长度为n的数列,要求把这个数列划分为任意块,每块的元素和小于m,使得所有块的最大值的和最小 分析:这题很快就能想到一个DP方程 f[ i ]=min{ f[ j ] +max{ a[ k ] }}( b[ i ]<j<i,j<k<=i)     b[ i ]到 i的和大于m 这个方程的复杂度是O(n^2),明显要超时的(怎么discuss都说数据弱呢= =) 然后是优化了,首先当然是要优化一个最大…
[题目链接] $O(n^2)$ 效率的 dp 递推式:${ dp }_{ i }=min\left( dp_{ j }+\overset { i }{ \underset { x=j+1 }{ max }  } \left( { a }_{ x } \right)  \right) $,其中 $\sum _{ x=j+1 }^{ i }{ { a }_{ i } } \le m$. 尝试着换一个角度看待这个问题,有一个序列 $a$,假设 $b_i$ 表示 $i$ 最左能扩展到 $b_i$ 位置,…
题意: 给定含有n个元素的数列a,要求将其划分为若干个连续子序列,使得每个序列的元素之和小于等于m,问最小化所有序列中的最大元素之和为多少?(n<=105.例:n=8, m=17,8个数分别为2 2 2 | 8 1 8 |1 2,答案为12.) 思路: 想明白一个队列+一个set就能完美解决这个问题? 首先DP的转移式子是:dp[i]=min( dp[j] +max[j+1, i]  ),且sum[i]-sum[j]<=m,j为枚举的断开处.暴力寻找一个合适的j的复杂度为O(n2).那么问题就…
dp+单调性+平衡树 在看某篇论文中看到这道题,但是那篇论文不如这个http://www.cnblogs.com/staginner/archive/2012/04/02/2429850.html 大神的空间写的好(还是说我太弱需要详解……). 其实要说的在大神的博客里面已经说的很好…… 比如f[i],然后j表示满足a[j+1]+a[j+2]+……+a[i]<=m的最小值.然后我们假定a[j]--a[i]中最大数的下标为k,那么就有j+1<=l<=k时,f[j+1]+a[k]<=f…
题目: Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subsequence of the original sequence. Every part must satisfy that the sum of the integers in the part is…
[题解]Cut the Sequence(贪心区间覆盖) POJ - 3017 题意: 给定一大堆线段,问用这些线段覆盖一个连续区间1-x的最小使用线段的数量. 题解 考虑一个这样的贪心: 先按照左端点排序,若左端点一样则谁长谁在前.现在判无解就方便了,记录一下前缀max即可.然后现在要最小化选择. 记录一个最右端点\(R\),一个暴力的办法是暴力循环判断所有线段是否满足条件,这样显然超时,你决定优化一下常数,所以你记录一下从哪个线段开始才\(l_i \ge R\).你以为你是常数优化,其实你复…
DP + 单调队列优化 + 平衡树 好题 Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subsequence of the original sequence. Every part must satisfy that the sum of the intege…
题意 Language:Default Cut the Sequence Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 12238 Accepted: 3809 Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a con…
Cut the Sequence Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 8764   Accepted: 2576 Description Given an integer sequence { an } of length N, you are to cut the sequence into several parts every one of which is a consecutive subseque…