CF772A.Voltage Keepsake

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have nn devices that you want to use simultaneously.

The ii -th device uses aia_{i} units of power per second. This usage is continuous. That is, in λλ seconds, the device will use λaiλ·a_{i} units of power. The ii -th device currently has bib_{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 pp 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λ·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 00 units of power.

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

输入格式

The first line contains two integers, nn and pp ( 1<=n<=1000001<=n<=100000 , 1<=p<=1091<=p<=10^{9} ) — the number of devices and the power of the charger.

This is followed by nn lines which contain two integers each. Line ii contains the integers aia_{i} and bib_{i} ( 1<=ai,bi<=1000001<=a_{i},b_{i}<=100000 ) — the power of the device and the amount of power stored in the device in the beginning.

输出格式

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

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

Namely, let's assume that your answer is aa and the answer of the jury is bb . The checker program will consider your answer correct if .

输入输出样例

  • 输入#1

    2 1
    2 2
    2 1000
    

    输出#1

    2.0000000000
  • 输入#2

    1 100
    1 1
    

    输出#2

    -1
    
  • 输入#3

    3 5
    4 3
    5 2
    6 1
    

    输出#3

    0.5000000000

说明/提示

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/52/5 of a second, then switch to charge the second device for a 1/101/10 of a second.

首页