fork(1) download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7.  
  8. typedef unsigned int uint;
  9. typedef long long ll;
  10. typedef unsigned long long ull;
  11. typedef long double ld;
  12. typedef vector<ll> vll;
  13. typedef vector<char> vc;
  14. typedef vector<bool> vb;
  15. typedef vector<vll> vvll;
  16. typedef vector<vector<char>> vvc;
  17.  
  18.  
  19. #define int ll
  20. #define sz(s) (ll)s.size()
  21. #define all(s) (s).begin(),(s).end()
  22. #define rall(s) (s).begin(),(s).end(),greater<>()
  23. #define ln '\n'
  24. #define rtv(n) return void(cout<<n)
  25. #define fixset(n) cout<<fixed<<setprecision(n)
  26. #define getunique(v){sort(all(v));v.erase(unique(all(v)), v.end());}
  27. #define input(a) for(auto&it:a)cin>>it;
  28. #define print(a) for(auto&it:a)cout<<it<<" ";cout<<ln;
  29.  
  30.  
  31. template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  32. // less: it is the basic for comparison of two function. Use less_equal for ordered multiset.
  33. // order_of_key(k): Number of items strictly smaller than k
  34. // find_by_order(k): kth element in a set (counting from zero)
  35.  
  36. const int MOD = 1e9 + 7;
  37. const int MX = 1e5 + 2;
  38.  
  39.  
  40. void Sayman369() {
  41. ios_base::sync_with_stdio(false);
  42. cin.tie(nullptr);
  43. cout.tie(nullptr);
  44. }
  45.  
  46. void file() {
  47. #ifdef LOCAL
  48. freopen("input.txt", "r", stdin);
  49. freopen("output.txt", "w", stdout);
  50. #else
  51. // freopen("mex.in", "r", stdin);
  52. // freopen("output.txt", "w", stdout);
  53. #endif
  54. }
  55.  
  56. void preprocessing() {
  57.  
  58. }
  59.  
  60.  
  61. const int N = 5e4;
  62. int dp[N];
  63. int n;
  64. vll a;
  65.  
  66.  
  67. int rec(int sum) {
  68. if (sum < 0)return -1e5;
  69. if (sum == 0)return 0;
  70. int &ret = dp[sum];
  71. if (~ret)return ret;
  72.  
  73. for (auto &i: a) {
  74. ret = max(ret, rec(sum - i) + 1);
  75. }
  76. return ret;
  77. }
  78.  
  79. void solve(int tc) {
  80. cin >> n;
  81. a.resize(3);
  82. input(a);
  83. memset(dp, -1, sizeof dp);
  84. cout << rec(n);
  85. }
  86.  
  87. signed main() {
  88. Sayman369();
  89. file();
  90. preprocessing();
  91. int tc = 1;
  92. // cin >> tc;
  93. for (int i = 1; i <= tc; i++) {
  94. solve(i);
  95. }
  96.  
  97. return 0;
  98. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty