#P3743. 小鸟的设备
小鸟的设备
Description
Little Bird has devices that can be used simultaneously. The -th device consumes units of energy per second. Energy usage is continuous; that is, energy is not consumed instantaneously at a moment but at a constant rate. In other words, for any real number , the amount of energy consumed in seconds is units. Initially, the -th device stores units of energy.
Little Bird also has a power bank that can charge any one device, supplying units of energy per second. Charging is also continuous. You can charge any device at any time, and the time to switch from one device to another is negligible.
Little Bird wants to use all these devices together until some device’s energy drops to . Given the power bank, she wants to know the maximum duration she can keep all devices running together.
Input Format
The first line contains two integers .
The next lines each describe one device, giving two integers: the device’s and .
Output Format
If Little Bird can use these devices indefinitely, output .
Otherwise, output the maximum duration before some device’s energy becomes .
Let your answer be and the standard answer be . You will receive full credit on a test point only if satisfy .
2 1
2 2
2 1000
2.0000000000
1 100
1 1
-1
3 5
4 3
5 2
6 1
0.5000000000
Hint
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号