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 ai that is less than or equal to the denominator bi. 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

1N,K2×105

1aibi109

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 ai, each describing the numerator of Kevin's grade in the i-th course.

The third line will contain N space-separated integers bi, 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 106 of the actual answer.

Sample Input 1

Copy
3 2
1 2 3
2 5 3

Sample Output 1

Copy
72.2222222

Explanation for Sample 1

You can add one points to the first course, making it 23, then add one point to the second course, making it 36. Then, the average score is 0.666+0.5+130.72222222, which, as a percent, is 72.222222%. It can be proven that this solution is optimal.

Sample Input 2

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

Sample Output 2

Copy
59.7345122

Comments

There are no comments at the moment.