Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[101];
- int main(){
- int t, b, p, f, h, c,summ;
- cin >> t;
- for (int i = 0;i < t; ++i){
- summ = 0;
- cin >> b >> p >> f;
- cin >> h >> c;
- if (b < 2){
- continue;
- }
- if (h > c){
- while (b > 1 && p >= 1){
- b-=2;
- p-=1;
- summ+=h;
- }
- if (b > 1 && f >= 1){
- while ( b > 1 && f >= 1 ) {
- b-=2;
- f-=1;
- summ+=c;
- }
- }
- } else {
- while (b > 1 && f >= 1){
- b-=2;
- f-=1;
- summ+=c;
- }
- if (b > 1 && p >= 1){
- while ( b > 1 && p >= 1 ) {
- b-=2;
- p-=1;
- summ+=h;
- }
- }
- }
- b = 0;
- p = 0;
- f = 0;
- h = 0;
- c = 0;
- a[i] = summ;
- }
- for (int i = 0; i < t ;++i){
- cout << a[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement