#D6456. Fractional Knapsack Problem
Fractional Knapsack Problem
Fractional Knapsack Problem
You have items that you want to put them into a knapsack of capacity . Item () has weight and value for the weight.
When you put some items into the knapsack, the following conditions must be satisfied:
- The total value of the items is as large as possible.
- The total weight of the selected items is at most .
- You can break some items if you want. If you put () of item , its value becomes
Find the maximum total value of items in the knapsack.
Constraints
Input
:
The first line consists of the integers and . In the following lines, the value and weight of the -th item are given.
Output
Print the maximum total value of the items in a line. The output must not contain an error greater than .
Examples
Input
3 50 60 10 100 20 120 30
Output
240
Input
3 50 60 13 100 23 120 33
Output
210.90909091
Input
1 100 100000 100000
Output
100
inputFormat
Input
:
The first line consists of the integers and . In the following lines, the value and weight of the -th item are given.
outputFormat
Output
Print the maximum total value of the items in a line. The output must not contain an error greater than .
Examples
Input
3 50 60 10 100 20 120 30
Output
240
Input
3 50 60 13 100 23 120 33
Output
210.90909091
Input
1 100 100000 100000
Output
100
样例
1 100
100000 100000
100