对比解法
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
bool cmp(float, float);
int n = 0, num = 0;
cin >> n >> num;
float kucun[1000] = { 0 };
float shoujia[1000] = { 0 };
float quanzhong[1000] = { 0 };
float ret = 0;
for (int i = 0; i < n; i++)
cin >> kucun[i];
for (int i = 0; i < n; i++)
cin >> shoujia[i];
for (int i = 0; i < n; i++)
quanzhong[i] = shoujia[i] / kucun[i];
// 18 15 10
// 75 72 45
// 4.8 4.5 4.1
sort(quanzhong, quanzhong + n, cmp);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (shoujia[j] / kucun[j] == quanzhong[i])
{
if (num >= kucun[j])
{
ret += shoujia[j];
num -= kucun[j];
break;