KNPSACK - Knapsack
Harry is working on a project with Hermione, in which they need some amount of a specific magical powder. As Hermione is studious type, she instructs Harry to arrange X milligrams of powder while she do some other necessary work.
The powder is available in the market in packed form. Packets of different weights are available. There are M types of packets available in the market each having some price, further each type of packet is available in infinite numbers. Your task is to find what is the minimum amount Harry needs to spend so that he can buy at least X milligrams.
Assume that the max value of answer can be 200.00 only.
In the first line, you are given two integers representing X and M. Next M lines describe the packet details, where each line has two integers Wi(Weight of packet i) and Pi(Price of Packet i). Wi will be a integer where Pi will be decimal number of precision 2.
You need to print the min. money spent so that Harry can arrange at least X milligrams of powder. Answer must contain exactly two decimal places (i.e. 5 should be printed as 5.00 and 5.6 should be printed as 5.60).
"Assume that the max value of answer can be 200.00 only." DP[i] = max weight at total cost of i.
how to think of dp on this
You have an error in the problem statement. Pi should be of type float, not int.