intcmp(mooncake a, mooncake b){ return a.unitPrice > b.unitPrice; }
intmain(){ int n, total; cin >> n >> total; vector<mooncake> cake(n); for (int i = 0; i < n; i++) cin >> cake[i].amount; for (int i = 0; i < n; i++) cin >> cake[i].price; for (int i = 0; i < n; i++) { cake[i].unitPrice = cake[i].price / cake[i].amount; } sort(cake.begin(), cake.end(), cmp); float res = 0.0; for (int i = 0; i < n; i++) { if (total >= cake[i].amount) { res += cake[i].price; } else { res += cake[i].unitPrice * total; break; } total -= cake[i].amount; } printf("%.2f", res);