代码实现
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> PII; // 单价、货存
const int N = 1010;
int n, d;
PII q[N];
int main()
{
cin >> n >> d;
for (int i = 0; i < n; i++)
scanf("%lf", &q[i].second);
for (int i = 0; i < n; i++)
{
scanf("%lf", &q[i].first);
q[i].first /= q[i].second;
}
sort(q, q + n, [](auto &a, auto &b) {
return a.first > b.first;
});
double sum = 0;
int i = 0;
for (int i = 0; i < n; i++)
{
if (q[i].second <= d)
sum += q[i].first * q[i].second;
else
{
sum += q[i].first * d;
break;
}
d -= q[i].second;
}
printf("%.2lf\n", sum);
return 0;
}