随笔分类 - 动态规划 - 区间dp
摘要:思路一:(区间dp) dp[i][j] 表示合并区间 i ~ j 所能获得的最大收益 class Solution { public: int a[505]; int dp[505][505]; int stoneGameV(vector<int>& stoneValue) { int len =
阅读全文
摘要:题意 : 给你 n 个数字,相邻的数字如果相同,则代表他们是一个块的,每次操作可以将一个块的数字变成任意一种数字,求最小操作次数,将整个区间的所有数字变成相同的 思路分析 : 定义 dp[i][j][k] k = 0 / 1 , dp[i][j][0] 表示将区间变成和左边数字一样的最小操作次数,
阅读全文
摘要:There is one last gate between the hero and the dragon. But opening the gate isn't an easy task. There were n buttons list in a straight line in front
阅读全文
摘要:When we are focusing on solving problems, we usually prefer to stay in front of computers rather than go out for lunch. At this time, we may call for
阅读全文
摘要:Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon, they planned to play a game with some stones. There were n s
阅读全文
摘要:Here is a famous story in Chinese history. That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play hors
阅读全文
摘要:Let us define a regular brackets sequence in the following way: 1. Empty sequence is a regular sequence. 2. If S is a regular sequence, then (S) and [
阅读全文
摘要:There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is id
阅读全文
摘要:以一个经典题目引入到正题 : 有 n 堆石子 , 每两堆石子合并会花费一定的价值,所花费的价值即为 两堆石子上的价值和 , 问合并所有的石子后的最小花费 ? 思路分析 : 因为题干可以看成是对每个区间的 的操作,找到问题的子问题 , 即只有一堆石子, 即区间长度为 1 的情况 ,它并不要合并 , 所
阅读全文