-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkylskap.cpp
More file actions
44 lines (36 loc) · 1.11 KB
/
kylskap.cpp
File metadata and controls
44 lines (36 loc) · 1.11 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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define per(i, high) for (int i = high - 1; i >= 0; i--)
#define perr(i, high, low) for (int i = high - 1, i >= low; i++)
#define sz(container) ((int)container.size())
#define all(x) begin(x), end(x)
void fast() {
ios::sync_with_stdio(0);
cin.tie(0);
}
int main() {
fast();
ll p_a, k_a, p_b, k_b, n;
cin >> p_a >> k_a >> p_b >> k_b >> n;
ll best_a = -1, best_b = -1, best_cost = 3e5;
// Notera att vi adderar med två, detta då vi vill testa fallet då vi använder
// endast a_bilar
for (ll a_cars = 0; a_cars < 2 + n / k_a; a_cars++) {
for (ll b_cars = 0; b_cars < 2 + n / k_a; b_cars++) {
ll count = a_cars * k_a + b_cars * k_b;
if (count >= n) {
ll cost = a_cars * p_a + b_cars * p_b;
if (cost < best_cost) {
best_a = a_cars;
best_b = b_cars;
best_cost = cost;
}
}
}
}
cout << best_a << " " << best_b << " " << best_cost << endl;
return 0;
}