Skip to content
C

Fractional Knapsack

Mediumjavapythonccppjavascript

You have N items with values and weights and a bag of capacity W. You may take any fraction of an item. Maximise the total value carried.

Input Format

The first line contains an integer N. The second line contains N space-separated integers — the values. The third line contains N space-separated integers — the weights (all positive). The fourth line contains an integer W, the capacity.

Output Format

Print the maximum value with exactly two digits after the decimal point.

Input (stdin)

Output

Run your code to see output here...