Dropping Tests
Time limit1sMemory limit128 MB
Given n test scores a_i/b_i, drop exactly k so the remaining total correct over total questions, times 100, is as large as possible.
- Level
Medium7 of 10
- Topics
- Binary search, Greedy, Sorting
- Solved
- No attempts yet
Problem
In a certain course you take tests. If you answer out of questions correctly on test , your cumulative average is defined as
Given your test scores and a positive integer , determine the highest cumulative average you can achieve if you are allowed to drop any of your test scores.
For example, suppose you take three tests with scores , , and . Without dropping any test, your cumulative average is . However, if you drop the third test, your cumulative average becomes .
Input
The input contains multiple test cases, each consisting of exactly three lines.
The first line contains two integers and (, ). The second line contains integers giving for every . The third line contains positive integers giving for every . It is guaranteed that .
The end of input is marked by a test case with , which must not be processed.
Output
For each test case, print on a single line the highest cumulative average obtainable after dropping of the given test scores. Round the average to the nearest integer.
Hint
To avoid ambiguities due to rounding errors, the tests are constructed so that every answer is at least away from a rounding boundary (that is, you may assume the average is never something like 83.4997).