Maximize sum of subset of arrays under given cost

111 Views Asked by At

I have an array of n Objects with an int 'value' and another int 'cost'. I want to get the subset of size k (k < n) of that array that maximizes the sum of the values. For instance...

Value - Cost

32 - 24

25 - 17

39 - 40

10 - 10

47 - 44

0 - 10

18 - 10

I need to choose, say, 5 of those that will maximize value while staying below a certain total cost (say, 100). I don't get bonus points for having the lowest cost, only for having the highest value. I'm not looking to get the most bang for my buck, I'm looking to get the most bang, while staying below a given buck.

Is there just a name for the algorithm I'm looking for? I don't want to have to brute force it.

0

There are 0 best solutions below