Submission #93112

#TimeUsernameProblemLanguageResultExecution timeMemory
93112Nodir_BobievK blocks (IZhO14_blocks)C++14
53 / 100
2 ms504 KiB
# include <iostream> using namespace std; const int N = 200; int n, k; int a[N], dp[N][N]; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++){ for (int j = 0; j <= k; j++){ dp[i][j] = 1e8 + 1; } } for (int i = 1; i <= n; i++){ for (int j = 1; j <= min(k, i); j++){ int mx = a[i]; for (int t = i - 1; t >= j - 1; t--){ dp[i][j] = min(dp[i][j], dp[t][j - 1] + mx); mx = max(mx, a[t]); } } } cout << dp[n][k]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...