This page is still under construction.

Parts of this page are still being built. What you see may change.

Dropping Tests

Time limit1sMemory limit128 MB

Summary
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 nn tests. If you answer aia_i out of bib_i questions correctly on test ii, your cumulative average is defined as

100⋅∑i=1nai∑i=1nbi100 \cdot \dfrac{\sum_{i=1}^{n} a_i}{\sum_{i=1}^{n} b_i}

Given your test scores and a positive integer kk, determine the highest cumulative average you can achieve if you are allowed to drop any kk of your test scores.

For example, suppose you take three tests with scores 5/55/5, 0/10/1, and 2/62/6. Without dropping any test, your cumulative average is 100⋅(5+0+2)/(5+1+6)=50100 \cdot (5+0+2)/(5+1+6) = 50. However, if you drop the third test, your cumulative average becomes 100⋅(5+0)/(5+1)≈83.33≈83100 \cdot (5+0)/(5+1) \approx 83.33 \approx 83.

Input

The input contains multiple test cases, each consisting of exactly three lines.

The first line contains two integers nn and kk (1≤n≤10001 \le n \le 1000, 0≤k<n0 \le k < n). The second line contains nn integers giving aia_i for every ii. The third line contains nn positive integers giving bib_i for every ii. It is guaranteed that 0≤ai≤bi≤1,000,000,0000 \le a_i \le b_i \le 1{,}000{,}000{,}000.

The end of input is marked by a test case with n=k=0n = k = 0, which must not be processed.

Output

For each test case, print on a single line the highest cumulative average obtainable after dropping kk 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 0.0010.001 away from a rounding boundary (that is, you may assume the average is never something like 83.4997).

Examples4

  1. Example 1

    Input
    3 1
    5 0 2
    5 1 6
    4 2
    1 2 7 9
    5 6 7 9
    0 0
    
    Expected output
    83
    100
    
  2. Example 2

    Input
    3 0
    1 2 3
    2 4 6
    0 0
    
    Expected output
    50
    
  3. Example 3

    Input
    1 0
    7
    10
    0 0
    
    Expected output
    70
    
  4. Example 4

    Input
    2 1
    0 5
    3 5
    0 0
    
    Expected output
    100