I have n rational numbers. Out of that I have to select m numbers such that
sum of numerators of m numbers /sum denominators of m numbers is maximum.
e.g. if I have 3 numbers 1/1, 1/2, 2/4 and I have to select 2 numbers. Then combinations will be
If 1/1, 1/2 are used then 1+1/1+2 = 2/3
If 1/1, 2/4 are used then 1+2/1+4=3/5
If 1/2, 2/4 are used then 1+2/2+4=3/6=1/2
Maximum is 2/3
Suppose I have array of n integers specifying numerators, and other array of n integers of denominators. And number m. What will be strategy ?
The numbers in input need not be reduced rational number. e.g a number can be 4/6 and not necessarily 2/3.
EDIT: A brute force solution will be try all permutations by selecting m numbers from n. And then apply above formula to find result and then see which combination gives maximum result.
So I want to know if there is any mathematical formula or property or a smarted way than brute force way.