Problem was a little too long for the title, so here is the exact definition:
Input
Set of integers, L
Integer, K
Output
A subset of L such that:
- The sum of the subset is >= K
- The number of elements in the subset is minimized
- If multiple subsets both meet the above criteria, the subset with the lowest maximum value is preferred.
- If multiple subsets are still tied, the one with the lowest sum is preferred.
e.g.
Input
L = { 4, 2, 3, 1 }
K = 5
The first two criteria would yield {4, 2}, {4, 3}, {4, 1}, and {2, 3}. We would prefer {2, 3} since its maximum value (3) is least of those.
Return null or throw and exception if there is no subset that meets the criteria.
I'm a little worried that this problem is too related to the subset-sum problem and might be NP-complete.