L2-003 月饼 (25 分)
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
struct Moon
{
double ku;
double shou;
double dan;
};
Moon moon[maxn];
bool cmp(Moon a, Moon b)
{
return a.dan>b.dan;
}
int main()
{
int n,m;
double sum=0;
cin>>n>>m;
for(int i=0;i<n;i++) cin>>moon[i].ku;
for(int i=0;i<n;i++) cin>>moon[i].shou,moon[i].dan=moon[i].shou/moon[i].ku;
sort(moon,moon+n,cmp);
for(int i=0;i<n;i++)
{
if(moon[i].ku>=m)
{
sum+=m*moon[i].dan;
break;
}
else
{
sum+=moon[i].shou;
m=m-moon[i].ku;
}
}
cout<<setiosflags(ios::fixed)<<setprecision(2)<<sum;
}