hdu 1011 Starship Troopers_树状dp】的更多相关文章

题目链接 题意:给你一棵树(必须从根节点出发),每个节点上都有bug和value,你有m个骑士,每个骑士能消灭20个bug,你必须消灭该节点的全部bug才能拿到该节点的value,问最多能拿到value是多少. 思路:典型的背包dp ,  dp[n][m]=max(dp[n][m-x]+value,dp[n][m]) #include<iostream> #include<cstdio> using namespace std; #define N 110 #define INF…
Description A tree with N nodes and N-1 edges is given. To connect or disconnect one edge, we need 1 unit of cost respectively. The nodes are labeled from 1 to N. Your job is to transform the tree to a cycle(without superfluous edges) using minimal c…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1011 题意: 题目大意是有n个房间组成一棵树,你有m个士兵,从1号房间开始让士兵向相邻的房间出发,每个房间里有一个代价,代价是值/20个士兵, 同时有一个价值,问你花费这m个士兵可以得到的最大价值是多少. 思路: 树上背包,这题比较坑爹.士兵为0,输出0.要是一个房间的cost不足20的倍数也要补全20的倍数. dp[i][j]表示以i节点为子树的root使用j个士兵的最大价值( 不用管父节点 ),…
http://acm.hdu.edu.cn/showproblem.php?pid=1011   题意:每个节点有两个值bug和brain,当清扫该节点的所有bug时就得到brain值,只有当父节点被清空时,才可以清扫它          的子节点,而清扫需要一定的人员.给定M个人员,N个结点的树,求最大brain和   这看起来是一道非常简单的背包dp 但是 写完提交wa之后,我发现这道题,并不简单!因为他的题意并不是完全和我找到的题意一样(我承认我语文很差劲所以随便找个题解看题意..),题目…
You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with tunnels. Each room is occupied by some bugs, and their brains hide…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description You, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a h…
Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19362 Accepted Submission(s): 5130 Problem Description You, the leader of Starship Troopers, are sent to destroy a base of the bu…
题目链接 题意:给你一棵树,各个节点都有价值(除根节点),从根节点出发,选择m个节点,问最多的价值是多小. 思路:很明显是树状dp,遍历树时背包最优价值,dp[i][k]=max{dp[i][r]+dp[son[i]][k-r]} #include <iostream> #include<cstdio> #include<cstring> using namespace std; #define MAXN 250 struct node{ int from,to,nex…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 题意:职员之间有上下级关系,每个职员有自己的happy值,越高在派对上就越能炒热气氛.但是必须是他的上司不在场的情况.求派对happy值的和最大能是多少. PS:这是多组输入,一开始还没看出来... dp[i][0]代表第i个职员不来的情况下的快乐值,dp[i][1]是第i个职员来的情况下的快乐值 那很显然有 dp[上司][来] += dp[下属][不来];dp[上司][不来] += Max(…
题目:Anniversary party 题意:给出N各节点的快乐指数,以及父子关系,求最大快乐指数和(没人职员愿意跟直接上司一起玩): 思路:从底向上的树状DP: 第一种情况:第i个员工不参与,F[i][0] += max(F[k][1], F[k][0]);(k为i的儿子) 第二种情况:第i个员工参与,F[i][1] += F[k][0]; F[i][j]表示第i个员工是否参与: 边界:F[i][0] = 0:F[i][1] = 其快乐指数: #include <iostream> #in…