#P3743. 小鸟的设备

小鸟的设备

Description

Little Bird has nn devices that can be used simultaneously. The ii-th device consumes aia_i 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 kk, the amount of energy consumed in kk seconds is k×aik \times a_i units. Initially, the ii-th device stores bib_i units of energy.

Little Bird also has a power bank that can charge any one device, supplying pp 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 00. 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 n,pn, p.

The next nn lines each describe one device, giving two integers: the device’s aia_i and bib_i.

Output Format

If Little Bird can use these devices indefinitely, output 1-1.

Otherwise, output the maximum duration before some device’s energy becomes 00.

Let your answer be aa and the standard answer be bb. You will receive full credit on a test point only if a,ba, b satisfy abmax(1,b)104\dfrac{|a-b|}{\max(1,b)} \leq 10^{-4}.

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 100%100\% of the testdata, 1n1051 \leq n \leq 10^5, 1p1051 \leq p \leq 10^5, 1ai,bi1051 \leq a_i, b_i \leq 10^5.

Translated by ChatGPT 5