#include<iostream>
#include <queue>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include <iomanip>
#include <algorithm>
#pragma warning(disable:4996)
using namespace std;
struct yuebing
{
float kucun,value;
float xingjiabi;
};
bool cmp(yuebing a, yuebing b)
{
return a.xingjiabi > b.xingjiabi;
}
int main()
{
float n, sum;
cin >> n >> sum;
float a,b;
vector<yuebing> test(n);
for (int i = 0;i < n;i++)
{
getchar();
cin >> a;
test[i].kucun = a;
}
for (int i = 0;i < n;i++)
{
getchar();
cin >> b;
test[i].value = b;
}
for (int i = 0;i < n;i++)
{
test[i].xingjiabi = test[i].value / test[i].kucun;
}
sort(test.begin(), test.end(), cmp);
float yi=sum;
float jiazhi=0;
for (auto i = 0;i < n;i++)
{
if (yi - test[i].kucun <0)
{
jiazhi = jiazhi + yi* test[i].xingjiabi;
break;
}
else
{
yi= yi- test[i].kucun;
jiazhi = jiazhi + test[i].kucun * test[i].xingjiabi;
}
}
printf("%.2f\n",jiazhi);
//cout << jiazhi;
}
1020 月饼 (25 分)
最新推荐文章于 2024-08-10 22:58:42 发布