#P10505. Dropping Test

Dropping Test

Problem Description

In a certain course, you need to take nn tests.

If in test ii (which has a total of bib_i questions) you answered aia_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 kk, if you are allowed to drop any kk test scores, what is the maximum possible value of your cumulative average score.

Suppose you took 33 tests, with scores 5/55/5, 0/10/1, and 2/62/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×5+05+183.3383100\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 nn and kk.

The second line contains nn integers, representing all aia_i.

The third line contains nn integers, representing all bib_i.

When the input case has n=k=0n=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 kk test scores.

The result should be rounded to the nearest integer.

3 1
5 0 2
5 1 6
4 2
1 2 7 9
5 6 7 9
0 0
83
100

Hint

Constraints: 1n10001 \le n \le 1000, 0k<n0 \le k < n, 0aibi1090 \le a_i \le b_i \le 10^9

Translated by ChatGPT 5