Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define mp make_pair
- #define pb push_back
- const int N = 11111;
- const int INF = (int)1e18;
- int dp[N];
- signed main()
- {
- ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- int n,k;
- cin >> n >> k;
- int mn;
- for(int i=k+1;i<=n+k;i++)
- {
- mn = INF;
- cin >> dp[i];
- for(int j=i-1;j>=i-k-1;j--)
- {
- mn = min(dp[j],mn);
- }
- dp[i] += mn;
- }
- cout << dp[n+k];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement