문제
Farmer John is bringing his
Upon arrival, Farmer John is quite surprised by the new rules for this year's talent show:
(i) A group of cows of total weight at least
(ii) The group with the largest ratio of total talent to total weight shall win.
FJ observes that all of his cows together have weight at least
Problem credits: Brian Dean
입력
The first line of input contains
출력
Please determine the largest possible ratio of total talent over total weight Farmer John can achieve using a group of cows of total weight at least
예제
3 15
20 21
10 11
30 31
1066
In this example, the best talent-to-weight ratio overall would be to use just the single cow with talent 11 and weight 10, but since we need at least 15 units of weight, the optimal solution ends up being to use this cow plus the cow with talent 21 and weight 20. This gives a talent-to-weight ratio of (11+21)/(10+20) = 32/30 = 1.0666666..., which when multiplied by 1000 and floored gives 1066.