-
Notifications
You must be signed in to change notification settings - Fork 1
/
1207A.cpp
41 lines (39 loc) · 879 Bytes
/
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
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
while (n--) {
int b, p, f;
cin >> b >> p >> f;
int h, c;
cin >> h >> c;
int h2 = 0,
c2 = 0;
if (h > c) {
while ((p > 0) && (b > 1)) {
h2++;
p--;
b -= 2;
}
while ((f > 0) && (b > 1)) {
c2++;
f--;
b -= 2;
}
} else {
while ((f > 0) && (b > 1)) {
c2++;
f--;
b -= 2;
}
while ((p > 0) && (b > 1)) {
h2++;
p--;
b -= 2;
}
}
printf("%d\n", (h * h2) + (c * c2));
}
}