Given the weights and values of n items, we need to put these items in a knapsack of capacity "capacity". Write a program to get the maximum total value in the knapsack.

Problem Note

  • Items are given as (value, weight) pairs i.e. (val, wt).

Example 1

Input: Items[] = [ [60, 10], [100, 20], [120, 30] ] 
Knapsack Capacity(capacity) = 50
Output: Maximum possible value = 240  
Explanation:  By taking full items of 10 kg, 20 kg and 2/3rd of last item of 30 kg. Total value = 60 + 100 + 120*2/3 = 240