# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348301 | 2021-01-14T14:24:58 Z | Halogen | Stove (JOI18_stove) | C++14 | 1000 ms | 1644 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 8 ms | 364 KB | Output is correct |
14 | Correct | 12 ms | 364 KB | Output is correct |
15 | Correct | 12 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 8 ms | 364 KB | Output is correct |
14 | Correct | 12 ms | 364 KB | Output is correct |
15 | Correct | 12 ms | 364 KB | Output is correct |
16 | Correct | 19 ms | 1644 KB | Output is correct |
17 | Correct | 27 ms | 1644 KB | Output is correct |
18 | Correct | 129 ms | 1644 KB | Output is correct |
19 | Execution timed out | 1094 ms | 1644 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |