dp 背包
丿Star
这个作者很懒,什么都没留下…
展开
-
HDU2571: 命运(DP)
HDU2571: 命运穿过幽谷意味着离大魔王lemon已经无限接近了! 可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个机关。要知道,不论何人,若在迷宫中被困1小时以上,则必死无疑! 可怜的yifenfei为了去救MM,义无返顾地跳进了迷宫。让我们一起帮帮执着的他吧! 命运大迷宫可以看成是一个两维的方格阵列,如下图所示: ...原创 2018-12-02 15:32:14 · 122 阅读 · 0 评论 -
01背包 完全背包 分组背包
1. 01背包有N 件物品和一个容量为V 的背包。放入第i 件物品耗费的空间 是vi,得到的价值是wi。求解将哪些物品装入背包可使价值总和最大。根据题意,我们便可以设dp[i][j]为已经装了i件物品且最大容量为j得最大价值.此时,我们就可以枚举i和j进行动态规划的状态转移得到结论.那么dp[i][j]的最大价值是怎么转移的呢?当第i件物品不选的时候,相当于前i件物品相同的体积j的最大价...原创 2018-12-06 20:16:06 · 536 阅读 · 0 评论 -
最少拦截系统
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统...原创 2018-12-06 18:33:57 · 159 阅读 · 0 评论 -
饭卡 (01背包)
电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Input多组数据。对于每组数据: 第一...原创 2018-12-06 18:10:37 · 155 阅读 · 0 评论 -
Piggy-Bank (完全背包)
Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simp...原创 2018-12-06 18:00:58 · 134 阅读 · 0 评论 -
The Triangle
73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top an...原创 2018-12-06 16:44:36 · 79 阅读 · 0 评论 -
Super Jumping! Jumping! Jumping!(dp)
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 ...原创 2018-12-08 15:46:44 · 111 阅读 · 0 评论 -
HDU1712:ACboy needs your help(分组背包)
题目描述: ACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to arrange the ...原创 2018-12-02 21:20:51 · 211 阅读 · 0 评论 -
Longest Ordered Subsequence(最长上升子序列)
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, ai2, ..., aiK), where 1 <= i1 < ...原创 2018-12-04 20:24:09 · 136 阅读 · 0 评论 -
Constructing Roads In JGShining's Kingdom
"OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to te...原创 2018-12-10 17:01:07 · 97 阅读 · 0 评论