#include<stdio.h>
#include<algorithm>
using namespace std;
struct thing{
double store, sell, price;
}things[1010];
bool cmp(thing a, thing b){
return a.price>b.price;
}
int main(){
int i, n;
double d, dun=0.0, money=0.0;
scanf("%d%lf",&n,&d);
for(i=0;i<n;i++){
scanf("%lf",&things[i].store);
}
for(i=0;i<n;i++){
scanf("%lf",&things[i].sell);
things[i].price=things[i].sell/things[i].store;
}
sort(things,things+n,cmp);
for(i=0;i<n;i++){
if(dun<d){
if((dun+things[i].store)<=d){dun+=things[i].store; money+=things[i].sell; }
else {money+=(d-dun)*things[i].price;break;}
}
}
printf("%0.2f\n",money);
return 0;
}
PAT-B1020
最新推荐文章于 2021-09-14 23:22:44 发布