-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeficit.cpp
56 lines (44 loc) · 899 Bytes
/
deficit.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
const int N = 2e5 + 11;
void solve() {
ll n,a,b,c;
cin>>n>>a>>b>>c;
n = n%4;
if(n==0)n=4;
ll deficit = abs(4-n);
ll for_a = INT32_MAX;
if(deficit == 1) {
for_a = a;
for_a = min(for_a, 3*c);
for_a = min(b+c, for_a);
}
ll for_b = INT32_MAX;
if(deficit == 2) {
for_b = b;
for_b = min(for_b,2*c);
for_b = min(2*a,for_b);
}
ll for_c = INT32_MAX;
if(deficit == 3) {
for_c = c;
for_c = min(a+b,for_c);
for_c = min(3*c, for_c);
}
cout<<min(for_a,min(for_b,for_c))<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
freopen("input.txt", "r", stdin);
int no_of_test_cases = 1;
// cin >> no_of_test_cases;
while (no_of_test_cases--) execute();
return 0;
}