#P468. 【例85.1】 金银岛
【例85.1】 金银岛
Description
On Treasure Island, there are types of metals, each with different weights (, , ..., ) and different values (, , ..., ). The total weight of metals that can be carried at once cannot exceed . What is the maximum value of metals that can be carried?
Note: Metals can be divided into any fraction, and the value of a metal is proportional to its weight.
Input Format
The first line contains the number of test cases , followed by groups of input.
Each test case consists of 3 lines: Line 1 contains a positive integer (), representing the maximum weight capacity. Line 2 contains a positive integer (), representing the number of metal types. Line 3 contains positive integers: , , , , ..., , , representing the total weight and total value of the first, second, ..., -th type of metal (, ).
Output Format
lines, each containing the result for one test case. The output should be accurate to 2 decimal places.
Sample
2
50
4
10 100 50 30 7 34 87 100
10000
5
1 43 43 323 35 45 43 54 87 43171.93
508.00