Advertisement
leminhkt

noname26 (BTICK)

Mar 16th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define iFOR(i, a, b) for(int i=(a); i<=(b); i++)
  3. #define iFORn(i, n) for(int i=1; i<=(n); i++)
  4. #define pb(x) push_back(x)
  5. using namespace std;
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.         //=================declare=================
  14.     int n, k, p1, p2;
  15.     vector<int> a={0};
  16. //=================..end..=================
  17. int main(){
  18.     //freopen("BTICK.inp", "r", stdin);
  19.     //freopen("BTICK.out", "w", stdout);
  20.     //ios_base::sync_with_stdio(0); cin.tie(0);
  21.         //=================code=================
  22.     cin>>n>>k>>p1>>p2;
  23.     iFORn(i, k-1) a.pb(a[i-1]+p1);
  24.     iFOR(i, k, n) a.pb(min(a[i-1]+p1, a[i-k]+p2));
  25.     cout<<a[n];
  26. //=================end.=================
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement