具体代码:#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+10;
struct mooncake{
double store,sell,price;
}c[N];
bool cmp(mooncake a,mooncake b){
return a.price>b.price;
}
int main(){
int n;
double d;
cin>>n>>d;
for(int i=0;i<n;i++)cin>>c[i].store;
for(int i=0;i<n;i++)cin>>c[i].sell,c[i].price=c[i].sell/c[i].store;
sort(c,c+n,cmp);
double ans;
for(int i=0;i<n;i++){
if(c[i].store<=d){
d-=c[i].store;
ans+=c[i].sell;
}else{
ans+=c[i].price*d;
break;
}
}
cout<<fixed<<setprecision(2)<<ans;
return 0;
}