#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct inv {
double amount;
double price;
double ppu;
bool operator<(const inv &b) const {
return ppu > b.ppu;
}
};
#define N 1000
int main(int argc, char **argv) {
int n;
double d;
inv is[N] = {{}};
cin >> n >> d;
for(int i = 0; i < n; i ++) {
scanf("%lf", &is[i].amount);
}
for(int i = 0; i < n; i ++) {
scanf("%lf", &is[i].price);
is[i].ppu = is[i].price / is[i].amount;
}
sort(is, is+n);
double r = d;
double profit = 0;
for(int i = 0; i < n; i ++) {
if(r >= is[i].amount) {
profit += is[i].price;
r -= is[i].amount;
}
else {
profit += (is[i].ppu * r);
break;
}
}
printf("%.2lf\n", profit);
return 0;
}
1070. Mooncake (25)
最新推荐文章于 2021-01-23 23:26:10 发布