#include <iostream>
#include <algorithm>
using namespace std;
struct node{
double cunliang, shoujia, danjia;
};
int cmp(struct node a, struct node b){
return a.danjia > b.danjia;
}
int main(){
int N, D;
double shouyi = 0;
cin >> N >> D;
node yuebing[N];
for(int i = 0; i < N; i++)
cin >> yuebing[i].cunliang;
for(int i = 0; i < N; i++)
cin >> yuebing[i].shoujia;
for(int i = 0; i < N; i++)
yuebing[i].danjia = yuebing[i].shoujia * 1.0 / yuebing[i].cunliang;
sort(yuebing, yuebing+N, cmp);
for(int i = 0; i < N; i++){
if(D <= yuebing[i].cunliang){
shouyi += yuebing[i].danjia * D;
break;
}
else{
shouyi += yuebing[i].shoujia;
D -= yuebing[i].cunliang;
}
}
printf("%.2f", shouyi);
}
C语言程序时设计-1020 月饼
最新推荐文章于 2022-10-20 22:37:17 发布