Solution report
Question Portal
Question:
The size of V and the number of items are N. Each item has value and capacity, and the maximum value that can be loaded into the package is obtained.
Ideas:
Basic 01 backpack.
DP [J] = max (DP [J], DP [J-C [I] + W [I])
#include
Bone Collector
Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)Total submission (s): 29249 accepted submission (s): 11967
Problem descriptionpolicyear
Solution report
Question Portal
Question:
Calculate the minimum value of the deposit tank.
Ideas:
Full backpack basis. The initial DP is the largest, and DP [0] = 0 indicates that the empty piggy bank has a value of 0;
The state transition equation is DP [J] = min (DP [J], DP [J-W [I] + C [I]).
#include
Piggy-bank
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)Total submission (s): 11691 accepted submission (s): 589
Happy Xiao Ming (Nanyang oj49) (01 backpack), Nanyang oj4901 backpackHappy James time limit: 1000 MS | memory limit: 65535 KB difficulty: 4
Description
James was very happy today. The new house purchased at home had the key. There was a very spacious room dedicated to him in the new house. Even more pleased, his mother said to him yesterday: "You have the final say about the items you need to purchase and how to arrange in your room, as l
integers in the first row of each set of data n,m (0After the M line, each row has two data ai (integer), bi (real) represents the first school of the application fee and may be the probability of getting an offer.The last entry has two 0.
OutputEach set of data corresponds to one output, indicating that the speakless may receive at least one offer of the maximum probability. Expressed as a percentage, accurate to one of the decimal places.
Sample Input10 34 0.14 0.25 0.30 0
Sample Output44%
Hi
Just say give you several items, then do 01 backpack, no more than it gives the first state of small B is how much.
Just look at the code, it's too much water.
#include
Backpack Nine Talk Board
Examples refer to "Information Science Orsay a pass"
Initialization is divided into two cases1, if the backpack requirements just fill the initialization f[0] = 0, f[1~v] =-inf;2, if do not need just fill f[0~v] = 0;
01 BackpackThere are n items and a backpack with a capacity of V. The cost of item I (i.e. volume, here
HDU2602 (0-1 backpack problem), hdu26020-1 backpack ProblemN-01 backpackTime Limit:1000 MSMemory Limit:32768KB64bit IO Format:% I64d % I64u
DescriptionMany years ago, in Teddy's hometown there was a man who was called "Bone Collector ". this man like to collect varies of bones, such as dog's, cow's, also he went to the grave...
The bone collector had a big bag with a volume of V, and along his trip of coll
or the 01 backpack time limit:10000Ms | Memory Limit:228000KB Difficulty:5
Describe
There are n items with a weight and value of WI and VI, from which the total weight of items not exceeding W is selected, and the maximum value of the sum of the values in all selection schemes is obtained.
Input
Multiple sets of test data.
The first row of each set of test data entered N
positive integers n and m, indicating the number of prizes, and the number of lotteries in small Ho's hands.The next n lines describe each line describing a prize, where I behaves two integers need (i) and value (i), meaning as described earlier.Test Data AssuranceFor 100% of data, the value of n does not exceed the value of 500,m no more than 10^5For 100% of data, need (i) does not exceed 2*10^5, value (i) does not exceed 10^3OutputFor each set of test data, output an integer ans that represen
ZOJ3662Math Magic (group backpack + full backpack), zoj3662mathmagicI-Math MagicTime Limit:3000 MSMemory Limit:32768KB64bit IO Format:% Lld % lluSubmit Status
Description
Yesterday, my teacher taught us about math: +,-, *,/, GCD, LCM... as you know, LCM (Least common multiple) of two positive numbers can be solved easily because of a * B = GCD (a, B) * LCM (a, B ).
In class, I raised a new idea: "how to ca
N, m, and k indicate that there are n pairs of k kinds of shoes, and you have m capacity;
Each pair of shoes has capacity p and value v. If you want to buy all k types of shoes, the maximum value of the shoes can be bought if the capacity is m;
Each pair of shoes can only be bought once (01 backpack). Each type of shoes must have at least one (group backpack: each group can have only one.
Note initializa
The main effect of the topic:
There are n pieces of furniture, each of which weighs (1≤wi≤100) and is transported to the destination with two handlebar vehicles. The two vehicles have a load limit of C1, C2 (1≤ci≤100), asking at least a few trips to get all the furniture to the destination.
The two cars must go with each other, even if a car is not carrying anything.
Ideas:
A
First on your own way:
Enumerating all the combinations of furniture that the first vehicle may carry, then a binar
[Problem description]Select some items from the items in the T group and put them in the backpack to find the minimum value of the remaining space.Restriction: You must select consecutive items from each group. That is to say, if there are n items in this group: item 1, Item 2, Item 3 ,... , Item n, you can only select item I, item I + 1 ,... , Item j, where 1 [Input]The first two positive integers v and T separated by spaces. The number of spaces and
Analysis:
First, this question cannot be considered a normal 01 backpack problem, because w
Question link http://acm.nyist.net/JudgeOnline/problem.php? PID = 1, 860
Code:
# Include
Explanation of backpack 01, full, and multiple
PS: If you think you can write well, just help me pin my blog. Thank you.
First, let's talk about dynamic planning. Dynamic Planning is just like recursion. We can only find local relationships. If we want to list them all, it is very difficult, such as the tower of Hanoi. You can say that it is an intuitive relationship to move all the layers except the last layer to 2, move the last layer to 3, and
(This old man's explanation won my mind, Special Recommendation: http://blog.csdn.net/insistgogo/article/details/8579597)
There are n items and a backpack with a capacity of v. The cost of the I-th item is C [I], and the value is W [I]. Solving which items are loaded into a backpack can make the total cost of these items not exceed the capacity of the backpack, a
Document directory
Problem description
Basic Ideas
Optimize space complexity
Initialization details
Problem description
Conversion to 0-1 backpack
Further Optimization-O (CN) Solution
This article mainly comes from the nine lectures on backpacks. I have selected a simple 0-1 backpack problem and a summary of the full backpack problem. I added the Python
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.