#P17456. [GESP202609 五级] 饮品调制
[GESP202609 五级] 饮品调制
Problem Description
You want to mix a beverage with exactly the right sweetness for your friends to taste.
There are kinds of ingredients available for mixing the beverage. The remaining amount of the -th ingredient is liters, and each liter contains 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 liters of the -th ingredient, then . The value can be any number between and (including decimals).
A beverage with exactly the right sweetness must have sweetness exactly equal to . 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 .
Input Format
The first line contains two integers , representing the number of ingredient types and the exactly-right sweetness.
The next lines each contain two integers , representing the remaining volume of the -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 of the test points, it is guaranteed that .
For all test points, it is guaranteed that , , , .
Translated by ChatGPT 5