#P4377. Maximizing Talent-to-Weight Ratio

    ID: 17623 Type: Default 1000ms 256MiB

Maximizing Talent-to-Weight Ratio

Maximizing Talent-to-Weight Ratio

Farmer John is taking his n cows (numbered from 1 to n) to a county fair for the annual Cow Show. The i-th cow has a weight of \(w_i\) and a talent level of \(t_i\), both of which are integers.

Due to the new rules for the contest, any group of cows entered must satisfy the following:

  1. The total weight of the chosen cows is at least \(W\). (This requirement is to ensure that it isn’t just one heavyweight cow competing.)
  2. The winning group is determined by the maximum ratio of total talent to total weight, i.e. maximize \(\frac{\sum t_i}{\sum w_i}\) among all valid groups.

It is guaranteed that the total weight of all cows is at least \(W\), so at least one valid team exists. Help Farmer John choose a team that attains the best possible talent-to-weight ratio!

inputFormat

The first line contains two integers \(n\) and \(W\) (number of cows and the minimum required weight, respectively).

Each of the following \(n\) lines contains two integers \(w_i\) and \(t_i\) representing the weight and talent of the \(i\)-th cow.

outputFormat

Output a single line with a floating point number representing the maximum possible talent-to-weight ratio, formatted to 6 decimal places.

sample

3 10
6 6
5 5
5 6
1.100000