注意库存不一定是整数,定义成double类型就好了!
/*
4.16 4.8 4.5
*/
#include <bits/stdc++.h>
using namespace std;
const int MAXn=1000+10;
int n,d;
struct goods{
double kc;
double price;
double one;
}good[MAXn];
bool cmp(goods a,goods b){
return a.one>b.one;
}
int main()
{
cin>>n>>d;
for(int i=0;i<n;++i)
cin>>good[i].kc;
for(int i=0;i<n;++i)
cin>>good[i].price;
for(int i=0;i<n;++i){
double a=good[i].price*1.0/good[i].kc;
good[i].one=a;
}
sort(good,good+n,cmp);
int sum=d;
double p=0;
for(int i=0;i<n;++i){
if(good[i].kc>=sum){
p+=good[i].one*sum;
break;
}else{
p+=good[i].one*good[i].kc;
sum-=good[i].kc;
}
}
printf("%.2lf",p);
return 0;
}