#P6733. 「Wdsr-2」间歇泉

「Wdsr-2」间歇泉

Description

There is a geyser that produced nn cups of water. For some reasons, each cup has a different temperature and volume. The temperature of the ii-th cup is cic_i, and the volume is aia_i.

Now mix any two cups of water. Each time you mix two cups, you will get a new temperature value. Find the kk-th highest possible temperature value (ignoring heat loss).

It is recommended that your answer keep at least 3\bm 3 digits after the decimal point (it will be accepted if the difference from the standard answer is within 102\bm{10^{-2}}).

Input Format

The first line contains two integers n,kn, k, as described above.

The next nn lines each contain two numbers ai,cia_i, c_i.

Output Format

Output one real number, representing the kk-th highest temperature after mixing.

5 1
1 5
4 2
5 3
2 3
1 4
4.500

Hint

Explanation for Sample 1

Mixing the 11-st and the 55-th cups gives a temperature value of 4.54.5. It can be seen that this is the highest possible water temperature.

Sample 2

See the attached files pour2.in/pour2.ans\textbf{\textit{pour2.in/pour2.ans}}.

Constraints and Notes

This problem uses bundled testdata.

  • Subtask 1 (10 pts)\textbf{Subtask 1}\text{ (10 pts)}: 1n101\le n\le 10.
  • Subtask 2 (40 pts)\textbf{Subtask 2}\text{ (40 pts)}: guaranteed k=1k=1.
  • Subtask 3 (50 pts)\textbf{Subtask 3}\text{ (50 pts)}: no special restrictions.
  • Subtask 4 (0 pts)\textbf{Subtask 4}\text{ (0 pts)}: hack testdata.

For 100%100\% of the data: 1n1051\le n\le 10^5, 1kn×(n1)21\le k\le \dfrac{n \times (n - 1)}{2}, 1ai,ci1091\le a_i,c_i\le 10^9.

The time limit is 2 s\text{2 s} for Subtasks 2/3/4, and 1 s\text{1 s} for Subtask 1.

Prerequisite Knowledge

For two cups of water with volume and temperature (ai,ci),(aj,cj)(a_i,c_i),(a_j,c_j), the temperature after mixing is:

T=aici+ajcjai+ajT=\dfrac{a_ic_i+a_jc_j}{a_i+a_j}

Note

The testdata of this problem is generated using SvRan, taking only 3min3\min.

Translated by ChatGPT 5