#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int N = 1e5 + 10;
double s[N], c[N], b[N], w[N];
int n, k;
bool OK(double x){
for(int i = 1; i <= n; i ++){
w[i] = b[i] - x * s[i];
}
sort(w + 1, w + n + 1);
double ans = 0;
for(int i = n; i > k; i --){
ans += w[i];
}
if(ans >= 0)
return true;
return false;
}
int main(){
ios :: sync_with_stdio(false);
cin >> n >> k;
for(int i = 1; i <= n; i ++){
cin >> s[i];
}
for(int i = 1; i <= n; i ++){
cin >> c[i];
b[i] = s[i] * c[i];
}
double l = 0.0, r = 100000.0;
while(r - l > eps){
double mid = (l + r) / 2;
if(OK(mid)){
l = mid;
}
else{
r = mid;
}
}
cout << setiosflags(ios::fixed) << setprecision(8) << l << endl;
return 0;
}
2018牛客多校第五场A
猜你喜欢
转载自blog.csdn.net/qq_38759433/article/details/81513943
今日推荐
周排行