#include <iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include <algorithm>
using namespace std;
class Solution {
public:
double mincostToHireWorkers(vector<int>& quality, vector<int>& wage, int k) {
vector<double> real_wage;%每一次的真实工资倍率
vector<double> wage_sum;%实际发放的工资
double rate=0 , sum=0;
for (int i=0 ; i < quality.size() ; i++)%分别计算每一个人的倍率为1时
{
rate = (double)wage[i] / (double)quality[i];
for (int j = 0; j < quality.size(); j++)
{
if (rate * quality[j] >= wage[j])%如果工作质量乘上倍率大于期望工资,加入工资数组
{
real_wage.push_back(rate* quality[j]);
}
else% 如果小于存最大值
{
real_wage.push_back(INT_MAX);
}
}
sort(real_wage.begin(), real_wage.end());
for (int j = 0; j < k; j++)
{
sum = sum + real_wage[j];
}
wage_sum.push_back(sum);
sum = 0;
real_wage = {};
}
sort(wage_sum.begin(), wage_sum.end());
return wage_sum[0];
}
};
int main() {
Solution a;
vector<int> quality = { 10, 20, 5 };
vector<int> wage = { 70, 50, 30 };
int k = 2;
cout<<a.mincostToHireWorkers(quality, wage,k);
return 0;
}