#P6733. Mixing Waters: Find the k-th Highest Temperature
Mixing Waters: Find the k-th Highest Temperature
Mixing Waters: Find the k-th Highest Temperature
You are given n cups of water. The i-th cup contains water with temperature \(c_i\) and volume \(a_i\). When mixing any two cups, the temperature of the resulting water will be computed using the formula:
\(T = \frac{c_i \times a_i + c_j \times a_j}{a_i + a_j}\)
No heat is lost during the mixing process.
Your task is to determine the k-th highest temperature value among all possible mixtures of two distinct cups.
Note: Please ensure that your answer retains at least 3 decimal places. The answer is considered correct if it differs from the standard answer by no more than \(10^{-2}\).
inputFormat
The first line contains two integers n
and k
(\(2 \le n\le 10^3\) for example, though constraints are not strictly specified), separated by a space.
Each of the following n
lines contains two real numbers: ci
(temperature) and ai
(volume) for the i-th cup.
outputFormat
Output the k-th highest temperature value among all mixtures of any two cups. The result should be printed with at least 3 decimal places.
sample
3 1
30 1
20 1
10 1
25.000