P10505 Dropping Test

Description

In a certain course, you need to take $n$ tests. If in test $i$ (which has a total of $b_i$ questions) you answered $a_i$ questions correctly, then your cumulative average score is defined as $$100\times \dfrac{\displaystyle \sum_{i=1}^n a_i}{\displaystyle \sum_{i=1}^n b_i}$$ Given your test scores and a positive integer $k$, if you are allowed to drop any $k$ test scores, what is the maximum possible value of your cumulative average score. Suppose you took $3$ tests, with scores $5/5$, $0/1$, and $2/6$. Without dropping any test score, your cumulative average score is $$100\times \frac{5+0+2}{5+1+6} \approx 58.33 \approx 58$$ However, if you drop the third score, then your cumulative average score becomes $$100\times \frac{5+0}{5+1}\approx 83.33\approx 83$$

Input Format

The input contains multiple test cases. Each test case consists of three lines. For each test case, the first line contains two integers $n$ and $k$. The second line contains $n$ integers, representing all $a_i$. The third line contains $n$ integers, representing all $b_i$. When the input case has $n=k=0$, it indicates the end of input, and this case should not be processed.

Output Format

For each test case, output one line containing the result: the maximum possible cumulative average score when dropping $k$ test scores. The result should be rounded to the nearest integer.

Explanation/Hint

Constraints: $1 \le n \le 1000$, $0 \le k < n$, $0 \le a_i \le b_i \le 10^9$。 Translated by ChatGPT 5