
动态规划
小郑¥
这个作者很懒,什么都没留下…
展开
-
Maximum Sum of Products CodeForces - 1519D (区间DP)
题意给出两个长度为n ( 1 ≤ n ≤ 5000 ) a , b 可以最多一次对序列a 的某段子数组执行翻转操作,求出如何翻转使得∑i=1nai∗bi\sum_{i=1}^{n}a_{i}*b_{i}∑i=1nai∗bi最大。思路跑一遍区间DP,状态转移方程为dp[i][j]=dp[i+1][j−1]+a[i]∗b[j]+a[j]∗b[i]−a[i]∗b[i]−a[j]∗b[j]dp[i][j]=dp[i+1][j-1]+a[i]*b[j]+a[j]*b[i]-a[i]*b[i]-a[j]*b原创 2021-05-17 08:56:26 · 196 阅读 · 0 评论 -
Corn Fields POJ - 3254 状态压缩
问题:Farmer John has purchased a lush new rectangular pasture composed ofMbyN(1 ≤M≤ 12; 1 ≤N≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regretta...原创 2020-03-20 10:57:16 · 162 阅读 · 0 评论 -
Marbles CodeForces - 1215E 状态压缩dp
问题:Monocarp has arrangednncolored marbles in a row. The color of theii-th marble isaiai. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the sam...原创 2019-10-15 21:46:53 · 376 阅读 · 0 评论 -
Yet Another Substring Reverse CodeForces - 1234F 状态压缩
问题:You are given a string ss consisting only of first 2020 lowercase Latin letters ('a', 'b', ..., 't').Recall that the substring s[l;r]s[l;r] of the string ss is the string slsl+1…srslsl+1…sr . F...原创 2019-10-04 18:56:08 · 387 阅读 · 0 评论 -
Maximum Sum UVA - 108 (二维变一维)
问题:A problem that is simple to solve in one dimension is often much more difficult to solve in more thanone dimension. Consider satisfying a boolean expression in conjunctive normal form in which e...原创 2019-07-28 21:02:00 · 139 阅读 · 0 评论 -
Largest Rectangle in a Histogram HDU - 1506 (区间dp||单调栈)
问题:A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left s...原创 2019-07-25 18:00:23 · 152 阅读 · 0 评论 -
跑跑卡丁车 HDU - 1494 (动态规划dp)
问题:跑跑卡丁车是时下一款流行的网络休闲游戏,你可以在这虚拟的世界里体验驾驶的乐趣。这款游戏的特别之处是你可以通过漂移来获得一种加速卡,用这种加速卡可以在有限的时间里提高你的速度。为了使问题简单化,我们假设一个赛道分为L段,并且给你通过每段赛道的普通耗时Ai和用加速卡的耗时Bi。加速卡的获得机制是:普通行驶的情况下,每通过1段赛道,可以获得20%的能量(N2O).能量集满后获得一个加速卡(...原创 2019-07-25 17:38:36 · 359 阅读 · 2 评论 -
Max Sum Plus Plus HDU - 1024 (m段最大和)
问题:Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem....原创 2019-07-28 21:00:49 · 148 阅读 · 0 评论 -
Cheapest Palindrome POJ - 3280 +动态规划
问题:Keeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic ID tag that the system will read as the cows pa...原创 2019-07-28 21:01:08 · 159 阅读 · 0 评论 -
最长公共子序列(解析)
c[i,j]表示:(x1,x2....xi) 和 (y1,y2...yj) 的最长公共子序列的长度。(是长度哦,就是一个整数嘛)。公式的具体解释可参考《算法导论》动态规划章节这张DP表很是重要,从中我们可以窥见最长公共子序列的来源,同时可以根据这张表打印出最长公共子序列的构成路径最长公共子序列模板: 1 #include<cstdio> 2 #i...转载 2019-07-28 21:01:22 · 397 阅读 · 0 评论