Submission #204691

#TimeUsernameProblemLanguageResultExecution timeMemory
204691bogdan_ogorodniyStove (JOI18_stove)C++14
20 / 100
1099 ms47608 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5 * 1e3 + 1; const int inf = 1e9 + 7; int dp[N][N]; signed main() { int n, k; cin >> n >> k; vector <int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) dp[i][j] = inf; dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < k; j++) { for (int c = i; c < n; c++) { dp[c + 1][j + 1] = min( dp[i][j] + v[c] - v[i] + 1, dp[c + 1][j + 1] ); } } } cout << dp[n][k] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...