#include <cstdio>
#include <algorithm>
using namespace std;
struct Product{
double count;
double totalSell;
double danjia;
}product[1010];
bool cmp(Product a, Product b){
return a.danjia > b.danjia;
}
int main(){
int n;
double m;
double sum = 0;
scanf("%d%lf", &n, &m);
for(int i = 0; i < n; i++){
scanf("%lf", &product[i].count);
}
for(int i = 0; i < n; i++){
scanf("%lf", &product[i].totalSell);
product[i].danjia = product[i].totalSell / product[i].count;
}
sort(product , product + n, cmp);
for(int i = 0; i < n; i++){
if(m <= product[i].count){
sum = sum + product[i].danjia * m;
break;
}
else if(m > product[i].count){
sum = sum + product[i].totalSell;
m = m - product[i].count;
}
}
printf("%.2f", sum);
return 0;
}
PAT a1070题解
最新推荐文章于 2021-02-21 11:04:02 发布