In order to achieve this goal, Xiao Ming decided to give up the qualification of k games. Ask for the best.

For example, there are three small-scale competitions, with 5 questions, 1 question and 6 questions respectively. Xiao Ming predicts that he can make 5 questions, 0 questions and 2 questions respectively. If you take part in every game, you don't look very big. However, if you give up game 3, then the big guy is, look at the bigger guy.

Input

The input test file contains multiple sets of tests, each with three lines. The first line has two integers, 1 ≤ n ≤ 1000 and 0 ≤ K < n. The second line has n integers, each a[i]. The third line contains n positive integers b[i]. Ensure that 0 ≤ a[i] < b[i] < 1, 000, 000, 000. The end of the file is identified by n = k = 0 and should not be processed.

Output

For each group of test data, output a line of integers, that is, the highest possible bigness after giving up k games. Bigwig degrees should be rounded to the nearest whole number.

Sample Input

3 1

5 0 2

5 1 6

4 2

1 2 7 9

5 6 7 9

0 0

Sample Output

83

100

Hint

In order to avoid ambiguity caused by rounding error, all the answers are at least 0.001 different from the division boundary (for example, the answer can never appear 83.4997).

It's only a binary search, TLE#include <iostream> #include <algorithm> #include <cstdio> using namespace std; int main() { int n,k; while(scanf("%d%d",&n,&k)&&n) { double a[1000],b[1000]; for(int i=0;i<n;++i) scanf("%lf",&a[i]);//Can do for(int i=0;i<n;++i) scanf("%lf",&b[i]);//How many? double low=0.0,high=100.0,mid,ant; while(high-low>0.00001) { double c[1000]; ant=0; mid=low+(high-low)/2.0; for(int i=0;i<n;++i) c[i]=a[i]-mid*b[i]; sort(c,c+n); for(int i=k;i<n;++i) ant+=c[i]; if(ant>0) low=mid; else high=mid; } printf("%.0f\n",mid*100); // cout<<mid<<endl; } return 0; }

#include <iostream> #include <algorithm> #include <cstdio> using namespace std; int main() { int n,k; while(scanf("%d%d",&n,&k)&&n) { int a[1000],b[1000]; int c[1000]; for(int i=0;i<n;++i) { scanf("%d",&a[i]);//Can do c[i]=i; } for(int i=0;i<n;++i) scanf("%d",&b[i]);//How many? double low=0.0,high=100,mid,ant=0; while(high-low>0.1) { mid=low+(high-low)/2.0; do { double aa=0,bb=0,ans; for(int i=0;i<n-k;++i) { aa+=a[c[i]]; // cout<<c[i]<<' '; } // cout<<endl; for(int i=0;i<n-k;++i) bb+=b[c[i]]; ans=100*(1.0*aa/bb)*1.0; if(ans>ant) { ant=ans; // cout<<ant<<endl; } }while(next_permutation(c,c+n)); if(ant>=mid) low=mid; else high=mid; } printf("%.0lf\n",ant); //cout<<ant<<endl; } return 0; }