
动态规划
文章平均质量分 64
免费的单身汉RainsdRop
这个作者很懒,什么都没留下…
展开
-
P1439 【模板】最长公共子序列(LCS+LIS)
文章目录Part1:题目链接Part2:题目Part3:思路关键1:关于这两个序列,它们是不同顺序的同数据序列。关键2:序列2和序列1的LCS长度,就是在序列2严格遵守序列1的排序规则下所能产生的LIS的长度。Part4:AC代码Part5:死宅时间Part1:题目链接点我就送屠龙宝刀[doge]Part2:题目Part3:思路突然高产,实则心无波澜,甚至还能再更一篇出来。如果只看题目的话,这道题就是1000%的LCS(Longest Common Sequence,最长公共子序列)。题目原创 2021-06-07 23:13:32 · 348 阅读 · 0 评论 -
P1091 [NOIP2004 提高组] 合唱队形(动态规划+LIS)
P1091 [NOIP2004 提高组] 合唱队形Part1:链接:点我就送屠龙宝刀[doge]Part2:题目Part3:思路隔了这么久,屑人再次捡起了他的节操,洗了洗,然后开始续写他的苦逼dp之路了。这道题我们可以用 LIS (Longest Increasing Subsequence,最长上升子序列) 来处理。LIS代码:///O(n^2)///lis1[i]:当考虑前i个元素后能够产生的最长子序列的长度for(int i=1; i<=n; i++){ lis原创 2021-06-07 18:48:47 · 335 阅读 · 0 评论 -
2021年牛客跨年场B:牛牛想起飞(dp)
链接:https://ac.nowcoder.com/acm/contest/9854/B题目思路牛客的跨年场没能参加上,主要是20个小时的火车折磨再加上2小时的晕车使得本就劳累不堪的我雪上加霜,整个人是崩溃的。原创 2021-01-01 22:31:07 · 223 阅读 · 2 评论 -
R - Milking Time(动态规划+01背包)
题目Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that she decides to schedule her next N (1 ≤ N ≤ 1,000,000) hours (conveniently labeled 0…N-1) so that she produces as much milk as possible.Farmer John has a原创 2020-11-18 22:03:26 · 177 阅读 · 0 评论 -
C - Monkey and Banana(动态规划)
题目A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the ba原创 2020-11-17 22:34:26 · 151 阅读 · 0 评论 -
M - Help Jimmy(动态规划+贪心)
题目“Help Jimmy” 是在下图所示的场景上完成的游戏。场景中包括多个长度和高度各不相同的平台。地面是最低的平台,高度为零,长度无限。Jimmy老鼠在时刻0从高于所有平台的某处开始下落,它的下落速度始终为1米/秒。当Jimmy落到某个平台上时,游戏者选择让它向左还是向右跑,它跑动的速度也是1米/秒。当Jimmy跑到平台的边缘时,开始继续下落。Jimmy每次下落的高度不能超过MAX米,不然就会摔死,游戏也会结束。设计一个程序,计算Jimmy到底地面时可能的最早时间。输入第一行是测试数据的组原创 2020-11-15 22:55:20 · 233 阅读 · 0 评论 -
牛客练习:Rabbit的工作(2)(背包dp)
链接:https://ac.nowcoder.com/acm/problem/21186题目Rabbit通过了上次boss的考核,现在她又遇到了一个问题。Rabbit接到了K个任务,每个任务她可以自由选择用i天去完成(1≤ i≤ N)。刁钻的boss想让Rabbit恰好用W天完成所有任务。已知Rabbit用i天完成一个任务能让boss获得的满意度为vi(因为完成任务的质量不同),她想知道在满足boss要求的情况下能让boss获得的总满意度最大是多少。输入第一行三个整数N,K,W。第二行N个整数原创 2020-11-11 23:07:04 · 171 阅读 · 0 评论 -
牛客练习_21314:codeforces (动态规划+01背包)
链接:https://ac.nowcoder.com/acm/problem/21314题目牛牛君正在打一场CF。比赛时间为T分钟,有N道题,可以在比赛时间内的任意时间提交代码。第i道题的分数为maxPoints[i],题目的分数随着比赛的进行,每分钟减少pointsPerMinute[i]。这是一场比较dark的Cf,分数可能减成负数。已知第i道题需要花费 requiredTime[i] 的时间解决,请问最多可以得到多少分?输入第一行输入两个整数N,T (1 ≤ N ≤ 50, 1 ≤ T原创 2020-11-09 22:47:57 · 434 阅读 · 0 评论 -
H - Tickets(动态规划)
题目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 is wandering when could he go back home as early as possible.A good approach, reducing the total time o原创 2020-11-07 22:52:58 · 214 阅读 · 0 评论 -
D - Super Jumping! Jumping! Jumping!(最长非连续子序列之和)
P - 红与黑题目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 game, so I introduce it to you now.The game can be played by two or more than two players. It原创 2020-10-28 23:32:23 · 198 阅读 · 0 评论 -
0-1 Knapsack Problem(背包问题)
0-1 Knapsack Problem(0-1背包问题) 链接:https://vjudge.net/problem/Aizu-DPL_1_B题目输入输出Print the maximum total values of the items in a line.数据范围题意现有N个价值为vi,重量为wi的物品,给出容量为W的背包。现需要将物品放入背包,但物品总重量<W。输出能够得到的最大价值。思路01背包问题(01背包:每种物品仅有一件,可以选择放或不放)。用子问题定原创 2020-10-27 23:04:03 · 2416 阅读 · 0 评论 -
Coin Changing Problem(01背包)
Coin Changing Problem(01背包) 题目Find the minimum number of coins to make change for n cents using coins of denominations d1, d2,…, dm.The coins can be used any number of times.输入Two integers n and m are given in the first line.The available denominatio原创 2020-10-26 23:08:53 · 333 阅读 · 0 评论