#P17456. [GESP202609 五级] 饮品调制

[GESP202609 五级] 饮品调制

Problem Description

You want to mix a beverage with exactly the right sweetness for your friends to taste.

There are nn kinds of ingredients available for mixing the beverage. The remaining amount of the ii-th ingredient is viv_i liters, and each liter contains sis_i grams of sugar. You may freely choose ingredients to add to the beverage, but the amount used for each ingredient must not exceed its remaining amount. That is, if you use kik_i liters of the ii-th ingredient, then 0≤ki≤vi0\le k_i\le v_i. The value kik_i can be any number between 00 and viv_i (including decimals).

A beverage with exactly the right sweetness must have sweetness exactly equal to tt. The sweetness of the final beverage you mix will be $\frac{\sum_{i=1}^{n}k_i\cdot s_i}{\sum_{i=1}^{n}k_i}$. To let more friends drink the beverage, ask what is the maximum number of liters of beverage with exactly the right sweetness that can be mixed. If it is impossible to mix a beverage with exactly the right sweetness, then the answer is considered to be 00.

Input Format

The first line contains two integers n,tn,t, representing the number of ingredient types and the exactly-right sweetness.

The next nn lines each contain two integers vi,siv_i,s_i, representing the remaining volume of the ii-th ingredient and the sugar mass contained per liter.

Output Format

Output one line with a decimal number, representing the maximum volume of beverage that can be mixed with exactly the right sweetness, rounded to three decimal places.

4 2
6 1
5 2
8 5
1 0
14.667
2 5
3 4
5 3
0.000

Hint

For 40%40\% of the test points, it is guaranteed that n=2n=2.

For all test points, it is guaranteed that 1≤n≤20001\le n\le 2000, 0≤t≤2000\le t\le 200, 1≤vi≤1001\le v_i\le 100, 0≤si≤2000\le s_i\le 200.

Translated by ChatGPT 5