题意:就是给定n个点,每个地点有value[i]的宝物,而且有的宝物必须是另一个宝物取了才能取,问取m个点可以获得的最多宝物价值。一个子节点就可以返回m个状态,每个状态表示容量为j(j 2 #include 3 #include 4 #include 5 #include 6 #include 7 ...
分类:
其他好文 时间:
2015-05-12 01:23:15
阅读次数:
161
Problem Description
Happy New Term!
As having become a junior, xiaoA recognizes that there is not much time for her to AC problems, because there are some other things for her to do, which makes her...
分类:
其他好文 时间:
2015-05-11 09:08:53
阅读次数:
128
Description
Zuosige always has bad luck. Recently, he is in hospital because of pneumonia. While he is taking his injection, he feels extremely bored. However, clever Zuosige comes up with a new ga...
分类:
其他好文 时间:
2015-05-10 20:35:40
阅读次数:
215
Problem Description
After months of hard working, Iserlohn finally wins awesome amount of scholarship. As a great zealot of sneakers, he decides to spend all his money on them in a sneaker store.There...
分类:
其他好文 时间:
2015-05-10 17:25:25
阅读次数:
116
Problem Description
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 arr...
分类:
其他好文 时间:
2015-05-10 15:49:01
阅读次数:
206
ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?
做法:设一个0节点,自身价值是0,dp[i][j]表示第i个节点,取了j个节点后的价值。因为先取父亲才能取儿子,所以要从dp[i][1] 开始转移。把子节点的状态转移到父亲节点。
因为和分组背包一样,子节点不能重复更新父亲...
分类:
其他好文 时间:
2015-04-30 23:20:35
阅读次数:
352
题目链接:http://codeforces.com/problemset/problem/148/E题目大意:有n组数据,每次可以从任意一组的两端取出1个数,问你取m个数最大能组成多少?思路:先将这n组数据变成每组内选i个最大能取到多少,就是合成若干个物品,然后就是分组背包问题。分组背包:问题有N...
分类:
其他好文 时间:
2015-04-30 07:32:31
阅读次数:
152
有n门课程,和m天时间,完成a[i][j]得到的价值为第i行j列的数字,求最大价值......
看过背包九讲的话,做这个就容易多了,其实就是简单的分组背包问题。
#include
#include
using namespace std;
int A[105][105];
int dp[105];
int main()
{
int n, m;
...
分类:
其他好文 时间:
2015-04-02 22:41:10
阅读次数:
155
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1712解释看这里:http://www.cnblogs.com/zhangmingcheng/p/3940332.html这题之前竟然做过,竟然不记得了,做了一个小时,竟然没A,(我连分组背包干什么的都忘了)...
分类:
其他好文 时间:
2015-03-31 19:32:28
阅读次数:
110
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3033After months of hard working, Iserlohn finally wins awesome amount of scholarship. As a great zealo...
分类:
其他好文 时间:
2015-03-28 15:38:53
阅读次数:
183