SHARE
TWEET

Untitled

lalalalalalalaalalla Oct 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iomanip>
  5. #include <queue>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <tuple>
  9. #include <iomanip>
  10. #include <stdio.h>
  11. #include <numeric>
  12. #include <map>
  13. #include <bitset>
  14. #include <set>
  15. #include <stack>
  16. #include <queue>
  17.  
  18. /*
  19. #pragma GCC optimize("Ofast,no-stack-protector")
  20. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  21. #pragma GCC optimize("unroll-loops")
  22. #pragma GCC optimize("fast-math")
  23. #pragma GCC optimize("section-anchors")
  24. #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  25. #pragma GCC optimize("vpt")
  26. #pragma GCC optimize("rename-registers")
  27. #pragma GCC optimize("move-loop-invariants")
  28. #pragma GCC optimize("unswitch-loops")
  29. #pragma GCC optimize("function-sections")
  30. #pragma GCC optimize("data-sections")
  31. #pragma GCC optimize("branch-target-load-optimize")
  32. #pragma GCC optimize("branch-target-load-optimize2")
  33. #pragma GCC optimize("btr-bb-exclusive")
  34. */
  35.  
  36. #define int long long
  37. #define ll long long
  38. #define ull unsigned long long
  39. #define all(a) a.begin(), a.end()
  40. #define pii pair<int, int>
  41. #define pb push_back
  42. #define ld long double
  43.  
  44.  
  45. using namespace std;
  46.  
  47. //const int INF = 1e13;
  48. //const int mod = 2600000069;
  49. //const int p = 179;
  50.  
  51. signed main() {
  52.     ios_base::sync_with_stdio(0);
  53.     cin.tie(0);
  54.     cout.tie(0);
  55.     int n, a, b, c, d;
  56.     cin >> n >> a >> b >> c >> d;
  57.     vector<int> dp(n + 1);
  58.     dp[0] = 0;
  59.     for (int i = 1; i < n + 1; i++) {
  60.         dp[i] = dp[i - 1] + 1;
  61.         if (i <= a) {
  62.             dp[i] = min(dp[i], b);
  63.         }
  64.         if (i <= c) {
  65.             dp[i] = min(dp[i], d);
  66.         }
  67.         if (i > a) {
  68.             dp[i] = min(dp[i], dp[i - a] + b);
  69.         }
  70.         if (i > c) {
  71.             dp[i] = min(dp[i], dp[i - c] + d);
  72.         }
  73.     }
  74.     cout << dp[n];
  75. }
  76. /*
  77. 35 10 9 20 17
  78. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top