# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
337227 |
2020-12-19T01:52:54 Z |
boykut |
K blocks (IZhO14_blocks) |
C++14 |
|
28 ms |
39916 KB |
#include <bits/stdc++.h>
using namespace std;
int dp[100001][101], a[100001];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 0; i <= 100000; i++) {
for (int j = 0; j <= 100; j++) {
dp[i][j] = INT_MAX;
}
}
dp[0][0] = 0;
dp[1][1] = INT_MAX;
for (int i = 2; i <= n; i++) {
dp[i][1] = max(dp[i - 1][1], a[i]);
}
auto getmax = [&](int l, int r) -> int{
int mx = INT_MIN;
for (int i = l; i <= r; i++)
mx = max(mx, a[i]);
return mx;
};
for (int j = 2; j <= k; j++) {
for (int i = 1; i <= n; i++) {
int mn = INT_MAX;
for (int l = 1; l < i; l++) {
mn = min(mn, dp[l][j - 1] + getmax(l + 1, i));
}
dp[i][j] = mn;
}
}
cout << dp[n][k] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
39916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
39916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
39916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
39916 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |