# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348301 | Halogen | Stove (JOI18_stove) | C++14 | 1094 ms | 1644 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
main() {
int N, K; scanf("%d %d", &N, &K);
int lst[N + 5]; lst[0] = 0;
for (int i = 1; i <= N; i++) scanf("%d", &lst[i]);
int dp[K + 5]; memset(dp, 63, sizeof(dp));
dp[K - 1] = 1;
for (int i = 2; i <= N; i++) {
for (int j = 0; j < K; j++) {
dp[j] = min(dp[j] + lst[i] - lst[i - 1], dp[j + 1] + 1);
// printf("%d ", dp[j]);
}
// printf("\n");
}
int ans = dp[K - 1];
for (int i = K - 2; i >= 0; i--) {
if (dp[i] == dp[K + 3]) break;
ans = min(ans, dp[i]);
}
printf("%d", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |