简单贪心。先买性价比高的。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std; double eps=1e-;
const int maxn=+;
int n;
struct X
{
double x;
double y;
}s[maxn];
double money; bool cmp(const X&a,const X&b)
{
return a.y/a.x>b.y/b.x;
} int main()
{
scanf("%d",&n);
scanf("%lf",&money);
for(int i=;i<=n;i++) scanf("%lf",&s[i].x);
for(int i=;i<=n;i++) scanf("%lf",&s[i].y);
sort(s+,s++n,cmp);
double ans=;
for(int i=;i<=n;i++)
{
if(money>=s[i].x)
{
ans=ans+s[i].y;
money=money-s[i].x;
}
else
{
ans=ans+money*s[i].y/s[i].x;
break;
}
}
printf("%.2lf\n",ans);
return ;
}