-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem_3.txt
60 lines (57 loc) · 1.24 KB
/
Problem_3.txt
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t, b, p, f, r = 0, c, h;
cin>>t;
while (t--)
{
cin>>b>>p>>f>>h>>c;
if (h > c)
{
if ((b / 2) >= p)
{
r = p * h;
b = (b / 2) - p;
if (b >= f)
{
r = r + f * c;
}
else
{
r = r + b * c;
}
}
else
{
r = (b / 2) * h;
}
}
else
{
if ((b / 2) >= f)
{
r = f * c;
b = (b / 2) - f;
if (b >= p)
{
r = r + p * h;
}
else
{
r = r + b * h;
}
}
else
{
r = (b / 2) * c;
}
}
cout<<r<<endl;
}
return 0;
}