-
Notifications
You must be signed in to change notification settings - Fork 2
/
1207A.cpp
43 lines (38 loc) · 1 KB
/
1207A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Author: Rushi Vachhani
* Platform: Codeforces
* Problem_ID: 1207A
* Language: C++
*/
#include<bits/stdc++.h>
using namespace std;
void solve() {
int buns, beef_patty, chicken_cutlet, price_hamburger, price_chickenburger;
cin >> buns >> beef_patty >> chicken_cutlet;
cin >> price_hamburger >> price_chickenburger;
int no_hamburgers, no_chickenburgers, profit=0;
buns = buns/2;
if(price_hamburger >= price_chickenburger) {
no_hamburgers = min(buns, beef_patty);
buns -= no_hamburgers;
no_chickenburgers = min(buns, chicken_cutlet);
}
else {
no_chickenburgers = min(buns, chicken_cutlet);
buns -= no_chickenburgers;
no_hamburgers = min(buns, beef_patty);
}
profit = price_hamburger*no_hamburgers + price_chickenburger*no_chickenburgers;
cout<<profit<<"\n";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}