as possible. At the same-time, you should guarantee, which A is not less than B.
Sample Input210 120 1310 1 20 230 1-1
Sample Output20 1040 40
Authorlcy
This is the subject of a multi-pack (the original value of the item is the value and cost of putting the item in the backpack, as it does not exceed the backpack capacity and the maximum value, which is th
This method limits the item weight and backpack capacity as well as the value of an integer#include #defineN 50//The number of items is not more than 50#defineM 1000//The backpack weighs no more thanintW[n];intV[n]; ShortFlag[n];//mark the selected itemintM[N][M];//Record Item ValueintGetmax (intAintb) { returnA>b?a:b;}intGetmin (intAintb) { returnA>b?b:a;}//Note: V and W start receiving values from s
1066:0/1 Backpack
time limit: 1 Sec
Memory Limit: MB
Title DescriptionA traveler has a backpack with a maximum of M kg, and now has n items, the weights of which are w1,w2,...,wn respectively, and their value is C1,C2,..., Cn. If there is only one piece of each item, the traveler can get the maximum total value.InputFirst line: Two integers, M (b
Two-dimensional cost backpack problems:
There are two different charges for each item.
This item must be paid at the same time;
Each price has one of the most affordable
Backpack capacity)
. Ask how to select an item to maximize the value. Set these two generations
Price is the price
1
And cost
2
, No
I
The two costs required for an item are:
A [I]
And
B [I]
. The maximum value (two types of
----- Edit by ZhuSenlin HDU
I have talked about the 001 backpack in my blog
Set the backpack capacity to V. There are N items in total. The size of each item is C [I], and the value of each item is W [I].
1) subproblem definition: F [I] [j] indicates the maximum value that can be obtained when several items are selected from the first I items are placed in a backpack
Ultraviolet A 10465 Homer Simpson (complete backpack: Two-Dimensional Target condition), 10465 homer
Ultraviolet A 10465 Homer Simpson (complete backpack: Two-Dimensional Target condition)
Http://uva.onlinejudge.org/index.php? Option = com_onlinejudge Itemid = 8 page = show_problem problem = 1406
Question:
There are two kinds of hamburgers (the number of hamburgers is unlimited). It takes n minutes to e
POJ 3181 Dollar Dayz 01 full backpack problem, pojdayz
01 A complete backpack problem.
This mainly describes the number of combinations. There are more people doing two-dimensional dp. here we can use one-dimensional dp.
One-dimensional transformation equation: dp [j] = dp [j-I] + dp [j]; where I represents the weight and j represents the current backpack capaci
First, sort the first n-1 from small to large, carry 01 backpack on the M-5, then the answer is m-DP [M-5]-A [n-1]As for why the most expensive food was last removed, rather than putting the most expensive food into the 01 backpack,Because if you can put the most expensive dish a [n-1] can be put in the backpack, then other dishes a [I] can certainly be placed in
Problem:
Assume that there are n items, each item has weight, and each item is also valuable. To put these items in a backpack, the carrying capacity of this backpack is limited, how can we maximize the total value of items in a backpack?
Symbol:
N: number of items
W: carrying weight of a backpack
W [I]: Weight of ite
Label: ACM algorithm DP Algorithm
Ultraviolet A 10465 Homer Simpson (complete backpack: Two-Dimensional Target condition)
Http://uva.onlinejudge.org/index.php? Option = com_onlinejudge Itemid = 8 page = show_problem problem = 1406
Question:
There are two kinds of hamburgers (the number of hamburgers is unlimited). It takes n minutes to eat one, and m minutes to eat the other. now you have a T minute to ask if you have to waste at least a
Method recursively searches in the solution space until the required solution or solution space has no dynamic knots.
(2) solving 0-1 knapsack algorithm analysis
The 0-1 knapsack problem is the subset selection problem. Generally, the 0-1 backpack problem is NP-hard. The solution space of the 0-1 knapsack problem can be represented by a subset tree. When searching for a spatial tree, as long as its left son node is a feasible node, the search enters
Question: Click to open the link
Question:
There are n items, each of which has two attributes: volume and value. A thief carries a V-sized backpack and wants to steal these items, q: What is the maximum value of K that thieves can steal?
Ideas:
This is different from the typical 01 backpack to find the optimal solution. It requires a K-level solution. Therefore, the most intuitive idea is to add one dim
Http: // 202.120.106.94/onlinejudge/problemshow. php? Pro_id = 542
Backpack exercise questions
Briefly summarize the question
There is a function f (x)
There are n unknown numbers X1 X2 x3.... XN
SIGMA (xi) = s
Evaluate the maximum value of F (X1) + f (X2) + f (X3) +... + f (Xn)
The maximum value of n s is 100.
Isn't that a general backpack? The value of each item changes as the volume you a
Link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3033
There are n kinds of shoes, m yuan in the hand, and N kinds of shoes belong to k brands, (1
Train of Thought: the variant of the backpack problem divides the items to be loaded into several categories, and there are limits on the selection of each item (generally choose at least one or more, because all items are grouped, the results of the previous I-1 class subcontracting will be processed
Question: poj 2484 cow Exhibition
Question: Give the nheaded ox. Each ox has a lucky Si and a smart ti. Now we need to select some cows to maximize the sum of the two values, provided that sum (SI) and sum (Ti) are both non-negative values.
Analysis: The data volume of this question is small, and it can be searched and trimmed.
Here we will talk about the idea of a 0-1 backpack. The obvious deformation of this question is that the item has two attri
Tags: Dynamic Planning 0-1 backpack ACM
Question:
There are a lot of monsters on each land on some independent land. It takes some time to kill every monster and get a certain amount of money to give the specified money M, find the minimum time required to get m money and select only one land to kill monsters.
Question:
Regardless of the data range, it is easy to think of a 0-1 backpack (dp (I, j) =
Question Link: Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1561
Theme: Get the vertex from the root of the tree. The maximum value is m points.
Solutions:
Cost = 1 tree type backpack.
There is a virtual root 0, and cost is required to take this virtual root, so the final result is DP [0] [M + 1].
This is a special backpack problem with cost = 1. There is an optimization on two for loops.
For (F + 1... j
Question Link: Http://poj.org/problem? Id = 1155
Theme: TV station broadcast program. For each root, its subnode may be a user or a transfer station. If it is a transfer station, you will spend money. If it is a user, you will receive money. Ask how many users can view the program at most without losing money.
Solutions:
Tree Type backpack. Cost = 1.
There is a virtual root 0, and cost is required to take this virtual root, so the final result is
.
Sample Input
2
10 1
20 1
3
10 1
20 2
30 1
-1
Sample output
20 10
40 40
Author
Lcy
There are n kinds of devices, each of which has a value and quantity. First, you need to calculate the total value of the N devices.
The two schools are equally divided as much as possible. If the average score is not completely equal, the first school should be divided into one more point.
Q: How many valuable devices can the two schools share?
Idea: Each device has a quantity and value. Each device can be
Getting started with a classic full backpack
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1114
Piggy-bank
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 5450 accepted submission (s): 2714Problem descriptionbefore 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 content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.