Advertisement
welleyth

4020. Orks

Dec 27th, 2020
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define mp make_pair
  7. #define pb push_back
  8.  
  9. const int N = 11111;
  10. const int INF = (int)1e18;
  11.  
  12. int dp[N];
  13.  
  14. signed main()
  15. {
  16.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  17.     //freopen("input.txt","r",stdin);
  18.     //freopen("output.txt","w",stdout);
  19.  
  20.     int n,k;
  21.     cin >> n >> k;
  22.  
  23.     int mn;
  24.  
  25.     for(int i=k+1;i<=n+k;i++)
  26.     {
  27.         mn = INF;
  28.         cin >> dp[i];
  29.         for(int j=i-1;j>=i-k-1;j--)
  30.         {
  31.             mn = min(dp[j],mn);
  32.         }
  33.         dp[i] += mn;
  34.     }
  35.  
  36.     cout << dp[n+k];
  37.  
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement