-
Notifications
You must be signed in to change notification settings - Fork 3
/
CutRibbon.cpp
executable file
·64 lines (58 loc) · 1.58 KB
/
CutRibbon.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
57
58
59
60
61
62
63
64
//https://codeforces.com/contest/1328
/*
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
int dp[5000];
int a, b, c;
int fun(int n){
if(n < 0) return INT_MIN;
if(n == 0) return 0;
int x, y, z, temp;
if(dp[n] == INT_MIN){
x = fun(n-a);
y = fun(n-b);
z = fun(n-c);
temp = max(x, max(y, z));
// if(temp == INT_MIN) dp[n] = INT_MIN;
dp[n] = temp+1;
}
return dp[n];
}
int32_t main(){
fastio;
int n;
loop(5000) dp[i] = INT_MIN;
cin >> n >> a >> b >> c;
dp[0] = 0;
cout << fun(n) << endl;
}
// int32_t main(){
// int n;
// cin >> n >> a >> b >> c;
// int ans = 0, temp;//fx = 0, fy = 0, fz = 0;
// for(int x = 0; x <= 4000; x++){
// for(int y = 0; y <= 4000; y++){
// if(a*x + b*y > n) break;
// temp = n - (a*x + b*y);
// if(temp%c == 0){
// if((x+y+temp/c) > ans) {
// ans = x+y+temp/c;
// }
// }
// }
// }
// cout << ans << endl;
// }