You are given a sack which can hold grain of weight w. You have grains of n different varieties, each weighing weighti kg and having a value of ₹ moneyi. What is the maximum worth of grain the sack can be filled with?
w: 12
n: 4
Grains (weight, value): [(5, 20), (8, 20), (4, 15), (5, 8)]
Output: 42.50
Explanation: Take 5 kg of 1st grain, 3 kg of 2nd grain and 4 kg of 3rd grain.
The first line contains an integer ‘T’ denoting the number of test cases.
For each test case, the input contains the following lines:
One line for each test case, with the maximum worth of grain that can be filled in the sack (accurate upto 2 decimal places).
2
12 4
5 20
8 20
4 15
5 8
10 3
4 8
2 5
3 8
42.50
21.00
1 <= t <= 10
1 <= w <= 109
1 <= n <= 5*104
1 <= weighti, valuei <= 104