随笔分类 - DP
摘要:https://leetcode.com/problems/maximum-subarray/ 题意为求最最大子数组之和 这是一道非常经典的动态规划的题目,用到的思路我们在别的动态规划题目中也很常用,以后我们称为”局部最优和全局最优解法“。基本思路是这样的,在每一步,我们维护两个变量,一个是全局最优
阅读全文
摘要:Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N) not nec
阅读全文
摘要:设有N堆石子排成一排,其编号为1,2,3,…,N。 每堆石子有一定的质量,可以用一个整数来描述,现在要将这N堆石子合并成为一堆。 每次只能合并相邻的两堆,合并的代价为这两堆石子的质量之和,合并后与这两堆石子相邻的石子将和新堆相邻,合并时由于选择的顺序不同,合并的总代价也不相同。 例如有4堆石子分别为
阅读全文
摘要: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
阅读全文
摘要:Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irrever
阅读全文
摘要:Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pl
阅读全文
摘要:在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个
阅读全文

浙公网安备 33010602011771号