Dastur qismi:
#include
#include
#include
using namespace std;
int main() {
const int profitA = 3;
const int profitB = 4;
const int timeA1 = 1;
const int timeA2 = 2;
const int timeB1 = 1;
const int timeB2 = 1;
const int maxTimeM1 = 450;
const int maxTimeM2 = 600;
vector products(2);
for (int a = 0; a <= maxTimeM1 / timeA1; a++) {
for (int b = 0; b <= maxTimeM2 / timeB2; b++) {
if (a * timeA1 + b * timeB1 <= maxTimeM1 && a * timeA2 + b * timeB2 <= maxTimeM2)
{
int profit = a * profitA + b * profitB;
products = max(products, {a, b, profit});
}
}
}
cout << products[0] << " " << products[1] << " " << products[2] << endl;
return 0;
}
Dastur natijasi:
Dostları ilə paylaş: |