dp--hdu1171(01背包)】的更多相关文章

Washing Clothes Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 9707   Accepted: 3114 Description Dearboy was so busy recently that now he has piles of clothes to wash. Luckily, he has a beautiful and hard-working girlfriend to help him…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:往长为L的线段上覆盖线段,要求:要么这些线段都在L的线段上,要么有不超过自身长度一半的部分在线段外面,最多有两条这样的线段(在两头). dp(i,j,k)表示前i个线段覆盖在长度为j的线段上,期中有k个线段不完全在这个线段上的最大价值.考虑线段长度的奇偶问题,所以事先把L和其他线段长度乘2,以便操作.所以枚举所有线段,一般情况,就是01背包的问题,dp(i,j,k)=max(dp(i,j…
Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to the <= N <= ) cows a thorough interview and determined two values <= Si <= ) of the cow…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1203 题目大意:Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了.要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的.Speakless没有多少钱,总共只攒了n万美元.他将在m个学校中选择若干的(当然要在他的经济承受范围内).每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能…
题意:给出规定的最高被抓概率m,银行数量n,然后给出每个银行被抓概率和钱,问你不超过m最多能拿多少钱 思路:一道好像能直接01背包的题,但是有些不同.按照以往的逻辑,dp[i]都是代表i代价能拿的最高价值,但是这里的代价是小数,显然不能这么做.还有,被抓概率显然不能直接相加,也不能相乘(越乘越小),这里就需要一些转化.我们把被抓概率转化为逃跑概率也就是1-被抓,那么逃跑概率就能直接相乘了.dp[i]代表拿到i价值的最大逃跑概率,这样又变成了01背包.最后求逃跑概率大于等于1-m的最大的钱. 代码…
01背包: 采药: https://www.luogu.org/problemnew/show/P1048 #include <iostream> #include <algorithm> using namespace std; ]; ],value[]; int main() { int T, n; cin >> T >> n; ; i < n; i++) { cin >> weight[i] >> value[i]; }…
题意:买东西,每个东西有三个特征值,p代表价格,q代表你手中钱必须不低于q才能买这个物品,v代表得到的价值. mark:又是变种01背包,每做一个变种的,就是一种提高.. 按照q - p以由大到小的顺序排序,然后进行01背包的DP即可. #include<stdio.h> #include<algorithm> #include<iostream> using namespace std; const int MAXN=5005; int dp[MAXN]; struc…
题目链接:http://codeforces.com/contest/742/problem/D D. Arpa's weak amphitheater and Mehrdad's valuable Hoses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Just to remind, girls in Arpa's lan…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1547 Description Now ,there are some rectangles. The area of these rectangles is 1* x or 2 * x ,and now you need find a big enough rectangle( 2 * m) so that you can put all rectangles into it(th…
The Dwarves of Middle Earth are renowned for their delving and smithy ability, but they are also master builders. During the time of the dragons, the dwarves found that above ground the buildings that were most resistant to attack were truncated squa…