Submission #312206

#TimeUsernameProblemLanguageResultExecution timeMemory
312206tevdoreK blocks (IZhO14_blocks)C++14
0 / 100
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, k; long long a[N], dp[N][101]; int main() { cin >> n >> k; for(int i = 1; i <= n; i++) cin >> a[i]; long long mx = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= k; j++) { mx = a[i]; for(int l = i - 1; l >= j - 1; l--) { if(dp[i][j] != 0) dp[i][j] = min(dp[i][j], dp[l][j - 1] + mx); if(dp[i][j] == 0) dp[i][j] = dp[l][j - 1] + mx; mx = max(mx, a[l]); } } } cout << dp[n][k] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...