Given a set of rational numbers, each defined as a pair of numerator and denominator, and a capacity constraint, select a subset of these rationals to maximize the total value. The value of each fraction is determined by its magnitude (numerator/denominator). The total value of the selected fractions should not exceed the given capacity.
Explanation: Select the fractions 5/6 and 3/4 to achieve the maximum value within the given capacity.
Explanation: Choose the fraction 2/3, then select 1/2 and 1/3 in proportion to fill the remaining capacity, maximizing the total value to 1.83333333333.
Maximize value with greedy fraction selection
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak