Print All Results In 0-1 Knapsack
medium
1. You are given a number n, representing the count of items. 2. You are given n numbers, representing the values of n items. 3. You are given n numbers, representing the weights of n items. 3. You are given a number "cap", which is the capacity of a bag you've. 4. You are required to calculate and print the maximum value that can be created in the bag without overflowing it's capacity. 5. Also, you have to print the indices of items that should be selected to make maximum profit. 6. You have to print all such configurations. Note -> Each item can be taken 0 or 1 number of times. You are not allowed to put the same item again and again.
Constraints
1 <= n <= 10^2 1 <= m <= 10^2 0 <= e1, e2, .. n * m elements <= 1000
Format
Input
A number n A number m e11 e12.. e21 e22.. .. n * m number of elements
Output
Check the sample output and question video.
Example
Sample Input
5
15 14 10 45 30
2 5 1 3 4
7
Sample Output
75
3 4
Question Video