## KNPSACK - Knapsack

no tags

```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.
Input:
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.
Output:
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).Constraints:1<=X<=10^71<=M<=1001<=Wi<=10^60.01<=Pi<=100.00
Input #1:3 21 1.102 0.83
Output #1:1.66
Input #2:3 22 0.951 0.50
Output #2:1.45``` wjli: 2020-08-03 21:48:51 "Assume that the max value of answer can be 200.00 only." DP[i] = max weight at total cost of i. sutharp777: 2020-05-19 22:44:52 how to think of dp on this urimaj: 2018-08-09 23:34:34 Nice dp! johbuntu: 2016-09-26 19:09:11 You have an error in the problem statement. Pi should be of type float, not int.