Codeforces Round 409 (rated, Div. 2, based on VK Cup 2017 Round 2)
C
Voltage Keepsake
Codeforces
未评级
原题
← BD →
翻译中…

You have $*n*$ devices that you want to use simultaneously.

翻译中…

The $*i*$-th device uses $*a*_{*i*}$ units of power per second. This usage is continuous. That is, in $λ$ seconds, the device will use $λ·*a*_{*i*}$ units of power. The $*i*$-th device currently has $*b*_{*i*}$ units of power stored. All devices can store an arbitrary amount of power.

翻译中…

You have a single charger that can plug to any single device. The charger will add $*p*$ units of power per second to a device. This charging is continuous. That is, if you plug in a device for $λ$ seconds, it will gain $λ·*p*$ units of power. You can switch which device is charging at any arbitrary unit of time (including real numbers), and the time it takes to switch is negligible.

翻译中…

You are wondering, what is the maximum amount of time you can use the devices until one of them hits $0$ units of power.

翻译中…

If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits $0$ power.

翻译中…

Input

翻译中…

The first line contains two integers, $*n*$ and $*p*$ ($1 ≤ *n* ≤ 100 000$, $1 ≤ *p* ≤ 10^{9}$) — the number of devices and the power of the charger.

翻译中…

This is followed by $*n*$ lines which contain two integers each. Line $*i*$ contains the integers $*a*_{*i*}$ and $*b*_{*i*}$ ($1 ≤ *a*_{*i*}, *b*_{*i*} ≤ 100 000$) — the power of the device and the amount of power stored in the device in the beginning.

翻译中…

Output

翻译中…

If you can use the devices indefinitely, print -1. Otherwise, print the maximum amount of time before any one device hits $0$ power.

翻译中…

Your answer will be considered correct if its absolute or relative error does not exceed $10^{ - 4}$.

翻译中…

Namely, let's assume that your answer is $*a*$ and the answer of the jury is $*b*$. The checker program will consider your answer correct if image.

翻译中…

Note

翻译中…

In sample test 1, you can charge the first device for the entire time until it hits zero power. The second device has enough power to last this time without being charged.

翻译中…

In sample test 2, you can use the device indefinitely.

翻译中…

In sample test 3, we can charge the third device for $2 / 5$ of a second, then switch to charge the second device for a $1 / 10$ of a second.

翻译中…

样例

Input #1
2 1
2 2
2 1000
Output #1
2.0000000000
InputCopy OutputCopy
Input #2
1 100
1 1
Output #2
-1
InputCopy OutputCopy
Input #3
3 5
4 3
5 2
6 1
Output #3
0.5000000000
InputCopy OutputCopy
题目信息
题号
801C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。