-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollege_Life_4.cpp
More file actions
63 lines (57 loc) · 1.3 KB
/
Copy pathCollege_Life_4.cpp
File metadata and controls
63 lines (57 loc) · 1.3 KB
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
61
62
63
/*
* @Date : 2021-03-09 21:13:38
* @Author : aerma7309
*/
#include <bits/stdc++.h>
using namespace std;
int FastIO = []() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
#define int long long
int n, e, h, a, b, c;
void solve()
{
int n, e, h, a, b, c, ans = 1e18;
cin >> n >> e >> h >> a >> b >> c;
for (int i = 0; i <= min({e, h, n}); i++)
{
int egg = e, choclate = h, person = n, cost = i * c;
egg -= i, choclate -= i, person -= i;
if (a < b)
{
//omelette
int item = min(egg / 2, person);
cost += (item * a);
person -= item;
//milkshake
item = min(choclate / 3, person);
cost += (item * b);
person -= item;
}
else
{
//milkshake
int item = min(choclate / 3, person);
cost += (item * b);
person -= item;
//omelette
item = min(egg / 2, person);
cost += (item * a);
person -= item;
}
if (person == 0)
ans = min(ans, cost);
}
cout << ((ans == 1e18) ? -1 : ans) << '\n';
}
signed main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}