Below the program will find the maximum value giving the following weight limit W. For example, having a W=5 (weight limit of 5), what is the maximum value?
The answer should be 5+2+2 == 9. These are the values added up. The 5 has a weight of 3 and each 2 has a weight of 1 total weights = 3+1+1
There’s another problem here, but it uses fractional weight. Note, you need to sort the values and weights, before calling the function.