Submission #768825

#TimeUsernameProblemLanguageResultExecution timeMemory
768825dimashhhStove (JOI18_stove)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6 + 123,MOD = 1e9 + 7; int n,k; ll a[N],dp[5100][5100],mn[5100]; void test(){ cin >> n >> k; for(int i = 1;i <= n;i++){ cin >> a[i]; } mn[0] = -a[1]; for(int i = 1;i <= k;i++){ mn[i] = 2e9; } for(int i = 1;i <= n;i++){ for(int j = 1;j <= min(i,k);j++){ //dp[i][j] = mn[j - 1] + 1 + a[i]; cout << dp[i][j] << ' '; } for(int j = 1;j <= min(i,k);j++) mn[j] = min(mn[j],dp[i][j] - a[i + 1]); //cout << '\n'; } cout << dp[n][k]; } int main(){ cin.tie(0);ios_base::sync_with_stdio(0); int T = 1; // cin >> T; while(T--){ test(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...