#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
struct good
{
double store;
double sale;
double price;
};//因为牵扯到单价的问题,数据类型全部为double
bool cmp(good a,good b)
{
return a.price >b.price ;
}
int main ()
{
int n,d;
cin>>n>>d;
good g[1005];
for(int i=0;i<n;i++)
cin>>g[i].store ;
for(int i=0;i<n;i++)
cin>>g[i].sale ;
for(int i=0;i<n;i++)
g[i].price =g[i].sale *1.0/g[i].store;
sort(g,g+n,cmp);
int m=0;
double max=0.0;
for(int i=0;i<n&&m<=d;i++)
{
if(m+g[i].store <=d){
max=max+g[i].price *g[i].store*1.0;
m=m+g[i].store ;
}
else
{
max=max+g[i].price *(d-m);
m=d+1;
}
}
printf("%.2lf\n",max);
return 0;
}
1020 月饼
最新推荐文章于 2024-06-01 12:36:06 发布