SHARE
TWEET

Untitled

lalalalalalalaalalla Nov 5th, 2019 70 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 <map>
  12. #include <bitset>
  13. #include <set>
  14. #include <stack>
  15. #include <queue>
  16. #include <unordered_set>
  17. #include <cassert>
  18.  
  19.  
  20. //#pragma GCC optimize("Ofast,no-stack-protector")
  21. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  22. //#pragma GCC optimize("unroll-loops")
  23. //#pragma GCC optimize("fast-math")
  24. //#pragma GCC optimize("section-anchors")
  25. //#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  26. //#pragma GCC optimize("vpt")
  27. //#pragma GCC optimize("rename-registers")
  28. //#pragma GCC optimize("move-loop-invariants")
  29. //#pragma GCC optimize("unswitch-loops")
  30. //#pragma GCC optimize("function-sections")
  31. //#pragma GCC optimize("data-sections")
  32. //#pragma GCC optimize("branch-target-load-optimize")
  33. //#pragma GCC optimize("branch-target-load-optimize2")
  34. //#pragma GCC optimize("btr-bb-exclusive")
  35.  
  36.  
  37. #define int long long
  38. #define ll long long
  39. #define ull unsigned long long
  40. #define all(a) a.begin(), a.end()
  41. #define pii pair<int, int>
  42. #define pb push_back
  43. #define ld long double
  44.  
  45.  
  46. using namespace std;
  47.  
  48. const int INF = 1e17;
  49. //const int mod = 2600000069;
  50. //const int p = 179;
  51.  
  52. signed main() {
  53.     ios_base::sync_with_stdio(0);
  54.     cin.tie(0);
  55.     cout.tie(0);
  56.     int n, a, b, c, d;
  57.     cin >> n >> a >> b >> c >> d;
  58.     vector<int> dp(n + 1, INF);
  59.     dp[0] = 0;
  60.     for (int i = 1; i < n + 1; i++) {
  61.         dp[i] = i;
  62.         if (i >= c) {
  63.             dp[i] = min(dp[i], dp[i - c] + d);
  64.         } else {
  65.             dp[i] = min(dp[i], d);
  66.         }
  67.         if (i >= a) {
  68.             dp[i] = min(dp[i], dp[i - a] + b);
  69.         } else {
  70.             dp[i] = min(dp[i], b);
  71.         }
  72.     }
  73.     cout << dp[n];
  74. }
  75. /*
  76.  
  77. */
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