xs

yehongchen 2023-09-23 19:59:46 2023-09-23 20:01:38 0

#include <bits/stdc++.h>

using namespace std;

struct data {

int v, p;

} a[50005];

int n, c;

double ans = 0;

bool cmp(data x, data y) { return x.p * y.v > y.p * x.v; }

int main() {

cin >> n >> c;

for (int i = 1; i <= n; i++) cin >> a[i].v;

for (int i = 1; i <= n; i++) cin >> a[i].p;

sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= n; i++) {
    if (a[i].v <= c) {
        ans = ans + a[i].p;
        c -= a[i].v;
    } else {
        ans = ans + c * ((double)a[i].p / a[i].v);
        break;
    }
}
printf("%.2lf\n", ans);
return 0;

}

{{ vote && vote.total.up }}