#P7430. [THUPC 2017] 组合数问题

[THUPC 2017] 组合数问题

Description

Xiaocong is a warrior.

Xiaocong sets out on a journey to save the world.

There are NN scallion monsters in front of Xiaocong.

The scallion monsters are powerful. For the ii-th scallion monster, its attack is aia_i and its defense is did_i.

Xiaocong's attack is AA and its defense is DD.

The cost for Xiaocong to defeat the ii-th scallion monster is A×di+D×aiA\times d_i + D\times a_i.

The cost for Xiaocong to defeat many scallion monsters is not the sum of the costs to defeat each one, but the maximum value.

Xiaocong now needs to defeat RR scallion monsters.

God-Scallion is the god of scallions. God-Scallion will evaluate Xiaocong for defeating RR scallion monsters. The evaluation is defined as the cost needed for Xiaocong to defeat these RR scallion monsters divided by the cost for Xiaocong, with the same attack and defense, to defeat all NN scallion monsters.

Since God-Scallion is the god of scallions, after Xiaocong selects the RR scallion monsters to be defeated, God-Scallion will set Xiaocong's attack and defense to make this evaluation as small as possible.

God-Scallion does not want this value to be negative, so if it is negative, God-Scallion will forcibly change it to 00.

Xiaocong is a warrior.

Xiaocong will not give in.

Xiaocong needs to choose RR scallion monsters so that the evaluation he can obtain from God-Scallion is as large as possible.

Find this evaluation value.

Xiaocong is very kind, so he wrote the mathematical expression of the evaluation value for you:

$$\max_{S\subseteq [N],|S|=R}\Big\lbrack\min_{A,D\in\Z^+}\dfrac{\max_{i\in S}(A\times d_i+D\times a_i)}{\max_{i\in [N]}(A\times d_i+D\times a_i)}\Big\rbrack$$

Input Format

The testdata contains multiple test cases.

For each test case, the first line contains two integers N,RN, R.

The next NN lines each contain two real numbers, representing ai,dia_i, d_i respectively.

Output Format

For each test case, output one real number per line as the answer. You need to ensure that the absolute error between your answer and the standard answer does not exceed 10610^{-6}.

3 3
1 3
2 5
2 3
5 1
1 5
2 4
3 3
4 2
5 1
1.000000
0.600000

Hint

Constraints: 1RN1031\le R\le N\le 10^3, ai,dia_i, d_i are both positive integers. The number of test cases does not exceed 5050. All attack and defense values are positive integers.

From THUPC (THU Programming Contest) 2017.

Translated by ChatGPT 5