Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define iFOR(i, a, b) for(int i=(a); i<=(b); i++)
- #define iFORn(i, n) for(int i=1; i<=(n); i++)
- #define pb(x) push_back(x)
- using namespace std;
- //=================declare=================
- int n, k, p1, p2;
- vector<int> a={0};
- //=================..end..=================
- int main(){
- //freopen("BTICK.inp", "r", stdin);
- //freopen("BTICK.out", "w", stdout);
- //ios_base::sync_with_stdio(0); cin.tie(0);
- //=================code=================
- cin>>n>>k>>p1>>p2;
- iFORn(i, k-1) a.pb(a[i-1]+p1);
- iFOR(i, k, n) a.pb(min(a[i-1]+p1, a[i-k]+p2));
- cout<<a[n];
- //=================end.=================
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement