题意:题目大意:有N个点,给出从a点到b点的距离,当然a和b是互相可以抵达的,问从1到n的最短距离 poj2387 Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, s…
Currency Exchange Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 22123 Accepted: 7990 Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and pe…
我搜索了一下,找到了一篇很好的博客,讲的挺详细:链接. 解析 多重背包的最原始的状态转移方程: 令 c[i] = min(num[i], j / v[i]) f[i][j] = max(f[i-1][j-k*v[i]] + k*w[i]) (1 <= k <= c[i]) 这里的 k 是指取第 i 种物品 k 件. 如果令 a = j / v[i] , b = j % v[i] 那么 j = a * v[i] + b. 这里用 k 表示的意义改变, k 表示取第 i 种物品的件数比…
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…
大神博客转载http://www.cppblog.com/MatoNo1/archive/2011/07/05/150231.aspx多重背包的单调队列初中就知道了但一直没(不会)写二进制优化初中就写过一直不写会心虚就写一下这个吧朴素方程dp[i,j]=max(dp[i-1,j-w[i]*k]+c[i]*k) w[i]*k<=j k<=j div w[i]忽略第一维dp[j]=max(dp[j-w[i]*k]+c[i]*k)复杂度O(m2n)以下是大神原文:将决策下标按照模w0的余数进行分类,…
题意: 已知一个序列 { a [ i ] } ,求取出从中若干不大于 KK 的区间,求这些区间和的最大值. 细节: 没有细节???感觉没有??? 分析: 听说有两种方法!!! 好吧实际上是等价的只是看似状态不同罢了~~~ QAQ Round1:枚举当前点取或不取,当前点 i 取的话那么在前 KK 的数中必须要选择一个数字点 k 不取并且将 k+1 到 i 做为新的区间,最后取最优的 k 作为转移记录下来,并且其满足最有子结构. 所以状态就是:dp[i][0/1] 表示以 i 为结尾是否取 i 最…