Arcadia Computing Contest 1 P5 - Hacking Grades

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Kevin is dissatisfied with his current grades. So, he hacks into the school's grading system to give himself some extra points! However, he can only give himself at most K points across all N of his courses before his teachers get suspicious.

His grades are represented as fractions, each with a numerator a_i that is less than or equal to the denominator b_i. When Kevin adds a point to a grade, both the numerator and the denominator increase by one.

In order to maximize the chances of getting into a good university, Kevin wants to make sure that the average of all his grades is as large as possible. Can you help Kevin with this task?

Constraints

1 \leq N, K \leq 2 \times 10^5

1 \leq a_i \leq b_i \leq 10^9

Input Specification

On the first line, you are given two space-separated integers, N and K.

The second line will contain N space-separated integers a_i, each describing the numerator of Kevin's grade in the i-th course.

The third line will contain N space-separated integers b_i, each describing the denominator of Kevin's grade in the i-th course.

Output Specification

Output a single number: the maximum average grade Kevin can obtain as a percentage. Your answer will be considered correct if it is within 10^{-6} of the actual answer.

Sample Input 1

3 2
1 2 3
2 5 3

Sample Output 1

72.2222222

Explanation for Sample 1

You can add one points to the first course, making it \frac{2}{3}, then add one point to the second course, making it \frac{3}{6}. Then, the average score is \frac{0.666+0.5+1}{3} \approx 0.72222222, which, as a percent, is 72.222222\%. It can be proven that this solution is optimal.

Sample Input 2

5 100
2 5 9 9 3
10 50 22 51 9

Sample Output 2

59.7345122

Comments

There are no comments at the moment.