Skip to content
CampusEduX

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.

Related Problems

  • Activity Selection
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Minimum Number of Coins
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Minimum Platforms
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...