boolcmp(Mooncake a, Mooncake b){ return a.price > b.price; }
intmain(){ int n = 0, d = 0;
cin >> n >> d;
Mooncake *mooncakes = new Mooncake[n]; for (int i = 0; i < n; i++) { cin >> mooncakes[i].memory; }
for (int i = 0; i < n; i++) { cin >> mooncakes[i].sale; mooncakes[i].price = mooncakes[i].sale / mooncakes[i].memory; }
sort(mooncakes, mooncakes + n, cmp);
double total = 0; for (int i = 0; i < n; i++) { if (d - mooncakes[i].memory >= 0) { total += mooncakes[i].sale; d -= mooncakes[i].memory; } else { total += mooncakes[i].price * d; break; } }