#P1570. Maximizing Coffee Taste

    ID: 14856 Type: Default 1000ms 256MiB

Maximizing Coffee Taste

Maximizing Coffee Taste

KC wants to enjoy a delicious cup of coffee by choosing exactly m out of n available condiments. Each condiment i has an associated preparation time c_i and a taste value v_i. When KC adds a set of condiments, the total preparation time is the sum of the selected c_i and the total taste is the sum of the selected v_i. The "taste per unit time" of the coffee is defined as:

\( \frac{\sum_{i \in S} v_i}{\sum_{i \in S} c_i} \)

where \( S \) is the set of exactly m chosen condiments. KC wants to maximize this ratio. Your task is to compute the maximum possible ratio.

Note: All formulas should be interpreted in \( \LaTeX \) format.

inputFormat

The first line contains two integers \( n \) and \( m \) (\(1 \le m \le n\)). Each of the next \( n \) lines contains two positive integers: \( c_i \) and \( v_i \), representing the time required and the taste value of the \( i \)-th condiment, respectively.

outputFormat

Output a single line containing the maximum possible value of \( \frac{\sum v_i}{\sum c_i} \) for the chosen \( m \) condiments. The answer will be accepted if its absolute or relative error does not exceed \(10^{-6}\).

sample

3 1
2 4
3 5
5 10
2.000000