시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB22121152.381%

문제

It is the 25th of September, 1825. Having just completed a record-setting wheat harvest, you wonder what to do with all this wheat. With a stroke of genius, you decide to use all of this wheat to bake your favourite type of cookie: stroopwafels. Of course, all this wheat should be ground to flour first. Because you cannot wait to start baking, you want to do this as fast as possible, so you decide to contact all flour mills in the Netherlands to ask them for help.

For each of these flour mills, you know how fast they can grind wheat to flour and how long it takes for a shipment to travel to and from the mill. You have enough grain ships available that can transport wheat to these mills, and bring the flour back from the mills. Dividing the wheat optimally between these mills, how long does it take until you have received back all the wheat?

As an example, consider the first sample case. To divide the wheat optimally between the three mills, you ship $400$ kilograms to the first, $120$ to the second, and $480$ to the third. The first mill requires $5$ hours to grind its wheat, the second requires $1$ hour, and the third requires $3$ hours. Combined with the shipping time to and from each mill, you receive all wheat back after exactly $11$ hours.

In the second sample case, we send all of the wheat to the first mill. This mill can grind all $100$ kilograms of wheat in $1$ hour, which together with the $2$ hours for shipping back and forth results in a total of $3$ hours. As the shipping for the second mill would already take $4$ hours, it is optimal to only use the first mill.

입력

The input consists of:

  • One line with two integers $n$ and $w$ ($1\leq n\leq 10^5$, $1\leq w\leq 10^9$), the number of mills and the amount of wheat you have, in kilograms.
  • $n$ lines, each with two integers $p$ and $t$ ($1\leq p, t\leq 10^9$), describing a mill that can process $p$ kilograms of wheat per hour, located $t$ hours away.

출력

Output the number of hours until you have received back all the wheat, when dividing the wheat optimally between the mills.

Your answer should have an absolute or relative error of at most $10^{-6}$.

예제 입력 1

3 1000
80 3
120 5
160 4

예제 출력 1

11

예제 입력 2

2 100
100 1
500 2

예제 출력 2

3

예제 입력 3

3 7
1 1
1 1
1 1

예제 출력 3

4.3333333

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2025 I번

  • 문제를 만든 사람: Maarten Sijm