/*从0开始*/
#include <bits/stdc++.h>
using namespace std;
struct mooncake{
double store; //库存量
double sell; //总售价
double price; //单价
}cake[1010];
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>>cake[i].store;
}
for(int i=0;i<n;i++)
{
cin>>cake[i].sell;
cake[i].price=cake[i].sell/cake[i].store;
}
sort(cake,cake+n,cmp); //对单价进行降序排序
double money=0;
/*选择单价最高的出售*/
for(int i=0;i<n;i++)
{
if(cake[i].store<=D)
{
D-=cake[i].store; //此时的市场需求量还剩多少
money+=cake[i].sell;
}
else
{
money+=cake[i].price*D;
break;
}
}
printf("%.2f\n",money);
return 0;
}
/*
3 20
18 15 10
75 72 45
*/
/*从1开始*/
#include <bits/stdc++.h>
using namespace std;
struct mooncake{
double store; //库存量
double sell; //总售价
double price; //单价
}cake[1010];
bool cmp(mooncake a,mooncake b)
{
return a.price>b.price;
}
int main()
{
int n; //月饼的数量
double D; //市场最大的需求量
scanf("%d%lf",&n,&D);
for(int i=0;i<n;i++)
{
cake[i].store=cake[i].sell=0;
}
for(int i=1;i<=n;i++)
{
scanf("%lf",&cake[i].store);
}
for(int i=1;i<=n;i++)
{
scanf("%lf",&cake[i].sell);
cake[i].price=cake[i].sell/cake[i].store;
}
sort(cake,cake+n,cmp); //对单价进行降序排序
double money=0;
/*选择单价最高的出售*/
for(int i=1;i<=n;i++)
{
if(cake[i].store<=D)
{
D-=cake[i].store; //此时的市场需求量还剩多少
money+=cake[i].sell;
}
else
{
money+=cake[i].price*D;
break;
}
}
printf("%.2f\n",money);
return 0;
}
/*
3 20
18 15 10
75 72 45
*/