Write a program below |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct patty {
int cost, count;
patty() {}
};
bool cmp(patty first, patty second)
{
|
|
}
vector<patty>pattyArray(3, patty());
int money;
int number;
int answer;
int main() {
for(int i = 0; i < 3; i++)
cin >> pattyArray.at(i).cost;
for (int i = 0; i < 3; i++)
cin >> pattyArray.at(i).count;
sort(pattyArray.begin(), pattyArray.end(), cmp);
cin >> money;
for (int i = 0; i < 3; i++) {
number = min(money / pattyArray.at(i).cost, pattyArray.at(i).count);
answer += number;
money -= number * pattyArray.at(i).cost;
}
cout << answer;
}
|