随笔分类 - dp入门
摘要:A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1,
阅读全文
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another
阅读全文
摘要:FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large
阅读全文
摘要:Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He i
阅读全文
摘要:在 ACM 能够开展之前,必须准备预算,并获得必要的财力支持。该活动的主要收入来自于 Irreversibly Bound Money (IBM)。思路很简单。任何时候,某位 ACM 会员有少量的钱时,他将所有的硬币投入到小猪储钱罐中。这个过程不可逆,因为只有把小猪储钱罐打碎才能取出硬币。在足够长的
阅读全文
摘要:题目链接:https://nanti.jisuanke.com/t/36118 环形数组的连续最大子段和,有两种情况。 1.最大和的这个子段没有包含头尾。所以直接dp[i] = max(dp[i-1]+a[i],a[i]) 2.最大和的这个子段包含了头尾。这个时候,最大和 = 累积和 - 连续子段最
阅读全文
摘要:Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this
阅读全文
摘要:题目: 有N堆石子,现要将石子有序的合并成一堆,规定如下: 1.每次只能移动相邻的2堆石子合并 2.合并花费为新合成的一堆石子的数量。 求将这N堆石子合并成一堆的总花费最小(或最大)。 样例: 输入:7 13 7 8 16 21 4 18 输出:239 说是简单dp,刚开始学dp还是有点困难,这个题
阅读全文
摘要:题目大意:有n 个物品,它们有各自的重量和价值,现有给定容量的背包,如何让背包里装入的物品具有最大的价值总和? 每个物品的重量设置为w[i],它的价值设置为c[i]。背包总容量为V。设F[ ] 是每个重量的最大价值。 状态转移方程为 F[i] = max( F[i-1], F[i-w[i]]+c[i
阅读全文
摘要:题意:数塔给出来了,求顶点到底边数之和的最大值。 思路:从底边倒推回去,更新从倒数第二排开始的每个值。例如 6 更新 为 6 + 12 = 18。 初始化:底层 dp[n][i] = arr[n][i]; 状态改变方程:dp[i][j] = max(dp[i+1][j] , dp[i+1][j+1]
阅读全文
摘要:给一个序列,求他的最长不下降序列。(并不是连续的序列) 题意不多叙述了。 思路: 定义一个f [ ] 数组,这个数组是用来保存 第 i 个元素的最长不下降序列值。 f [ ]数组里面的最大值,就是最长子序列。 例如: arr 13 7 9 16 38 24 37 18 44 19 21 22 f 1
阅读全文

浙公网安备 33010602011771号