# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101484 |
2024-10-16T08:59:27 Z |
TPhat |
K blocks (IZhO14_blocks) |
C++17 |
|
1000 ms |
82512 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define INF 1000000000
int n, k;
int a[100005];
int dp[105][100005];
signed main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
dp[1][i] = a[i];
for (int j = 1; j < i; j++) {
dp[1][i] = max(dp[1][i], a[j]);
}
}
for (int i = 2; i <= k; i++) {
for (int j = i; j <= n; j++) {
int max_val = 0;
dp[i][j] = INF;
for (int l = j; l >= i; l--) {
max_val = max(max_val, a[l]);
dp[i][j] = min(dp[i][j], dp[i-1][l-1] + max_val);
}
}
}
cout << dp[k][n] << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4600 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
11 |
Correct |
1 ms |
6480 KB |
Output is correct |
12 |
Correct |
1 ms |
4432 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
1 ms |
6604 KB |
Output is correct |
17 |
Correct |
1 ms |
4432 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4480 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4616 KB |
Output is correct |
6 |
Correct |
1 ms |
4600 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
11 |
Correct |
1 ms |
6480 KB |
Output is correct |
12 |
Correct |
1 ms |
8528 KB |
Output is correct |
13 |
Correct |
1 ms |
8528 KB |
Output is correct |
14 |
Correct |
2 ms |
10576 KB |
Output is correct |
15 |
Correct |
2 ms |
10756 KB |
Output is correct |
16 |
Correct |
2 ms |
14672 KB |
Output is correct |
17 |
Correct |
2 ms |
14672 KB |
Output is correct |
18 |
Correct |
2 ms |
10576 KB |
Output is correct |
19 |
Correct |
2 ms |
14672 KB |
Output is correct |
20 |
Correct |
3 ms |
18768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4600 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
11 |
Correct |
1 ms |
6480 KB |
Output is correct |
12 |
Correct |
1 ms |
4432 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
1 ms |
6604 KB |
Output is correct |
17 |
Correct |
1 ms |
4432 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
1 ms |
4432 KB |
Output is correct |
20 |
Correct |
1 ms |
4432 KB |
Output is correct |
21 |
Correct |
1 ms |
4480 KB |
Output is correct |
22 |
Correct |
1 ms |
4432 KB |
Output is correct |
23 |
Correct |
1 ms |
4616 KB |
Output is correct |
24 |
Correct |
1 ms |
4600 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4432 KB |
Output is correct |
27 |
Correct |
1 ms |
6480 KB |
Output is correct |
28 |
Correct |
1 ms |
6480 KB |
Output is correct |
29 |
Correct |
1 ms |
6480 KB |
Output is correct |
30 |
Correct |
1 ms |
8528 KB |
Output is correct |
31 |
Correct |
1 ms |
8528 KB |
Output is correct |
32 |
Correct |
2 ms |
10576 KB |
Output is correct |
33 |
Correct |
2 ms |
10756 KB |
Output is correct |
34 |
Correct |
2 ms |
14672 KB |
Output is correct |
35 |
Correct |
2 ms |
14672 KB |
Output is correct |
36 |
Correct |
2 ms |
10576 KB |
Output is correct |
37 |
Correct |
2 ms |
14672 KB |
Output is correct |
38 |
Correct |
3 ms |
18768 KB |
Output is correct |
39 |
Correct |
5 ms |
41464 KB |
Output is correct |
40 |
Correct |
1 ms |
4432 KB |
Output is correct |
41 |
Correct |
1 ms |
4432 KB |
Output is correct |
42 |
Correct |
1 ms |
4432 KB |
Output is correct |
43 |
Correct |
1 ms |
4432 KB |
Output is correct |
44 |
Correct |
1 ms |
4432 KB |
Output is correct |
45 |
Correct |
1 ms |
4432 KB |
Output is correct |
46 |
Correct |
1 ms |
4432 KB |
Output is correct |
47 |
Correct |
1 ms |
4432 KB |
Output is correct |
48 |
Correct |
1 ms |
6480 KB |
Output is correct |
49 |
Correct |
1 ms |
6480 KB |
Output is correct |
50 |
Correct |
2 ms |
6480 KB |
Output is correct |
51 |
Correct |
3 ms |
22864 KB |
Output is correct |
52 |
Correct |
3 ms |
22864 KB |
Output is correct |
53 |
Correct |
8 ms |
82468 KB |
Output is correct |
54 |
Correct |
9 ms |
82512 KB |
Output is correct |
55 |
Correct |
5 ms |
45392 KB |
Output is correct |
56 |
Correct |
8 ms |
82512 KB |
Output is correct |
57 |
Correct |
10 ms |
82512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4432 KB |
Output is correct |
2 |
Correct |
1 ms |
4432 KB |
Output is correct |
3 |
Correct |
1 ms |
4432 KB |
Output is correct |
4 |
Correct |
1 ms |
4432 KB |
Output is correct |
5 |
Correct |
1 ms |
4432 KB |
Output is correct |
6 |
Correct |
1 ms |
4600 KB |
Output is correct |
7 |
Correct |
1 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
4432 KB |
Output is correct |
9 |
Correct |
1 ms |
6480 KB |
Output is correct |
10 |
Correct |
1 ms |
6480 KB |
Output is correct |
11 |
Correct |
1 ms |
6480 KB |
Output is correct |
12 |
Correct |
1 ms |
4432 KB |
Output is correct |
13 |
Correct |
1 ms |
6480 KB |
Output is correct |
14 |
Correct |
1 ms |
6480 KB |
Output is correct |
15 |
Correct |
1 ms |
4432 KB |
Output is correct |
16 |
Correct |
1 ms |
6604 KB |
Output is correct |
17 |
Correct |
1 ms |
4432 KB |
Output is correct |
18 |
Correct |
1 ms |
6480 KB |
Output is correct |
19 |
Correct |
1 ms |
4432 KB |
Output is correct |
20 |
Correct |
1 ms |
4432 KB |
Output is correct |
21 |
Correct |
1 ms |
4480 KB |
Output is correct |
22 |
Correct |
1 ms |
4432 KB |
Output is correct |
23 |
Correct |
1 ms |
4616 KB |
Output is correct |
24 |
Correct |
1 ms |
4600 KB |
Output is correct |
25 |
Correct |
1 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4432 KB |
Output is correct |
27 |
Correct |
1 ms |
6480 KB |
Output is correct |
28 |
Correct |
1 ms |
6480 KB |
Output is correct |
29 |
Correct |
1 ms |
6480 KB |
Output is correct |
30 |
Correct |
1 ms |
8528 KB |
Output is correct |
31 |
Correct |
1 ms |
8528 KB |
Output is correct |
32 |
Correct |
2 ms |
10576 KB |
Output is correct |
33 |
Correct |
2 ms |
10756 KB |
Output is correct |
34 |
Correct |
2 ms |
14672 KB |
Output is correct |
35 |
Correct |
2 ms |
14672 KB |
Output is correct |
36 |
Correct |
2 ms |
10576 KB |
Output is correct |
37 |
Correct |
2 ms |
14672 KB |
Output is correct |
38 |
Correct |
3 ms |
18768 KB |
Output is correct |
39 |
Correct |
5 ms |
41464 KB |
Output is correct |
40 |
Correct |
1 ms |
4432 KB |
Output is correct |
41 |
Correct |
1 ms |
4432 KB |
Output is correct |
42 |
Correct |
1 ms |
4432 KB |
Output is correct |
43 |
Correct |
1 ms |
4432 KB |
Output is correct |
44 |
Correct |
1 ms |
4432 KB |
Output is correct |
45 |
Correct |
1 ms |
4432 KB |
Output is correct |
46 |
Correct |
1 ms |
4432 KB |
Output is correct |
47 |
Correct |
1 ms |
4432 KB |
Output is correct |
48 |
Correct |
1 ms |
6480 KB |
Output is correct |
49 |
Correct |
1 ms |
6480 KB |
Output is correct |
50 |
Correct |
2 ms |
6480 KB |
Output is correct |
51 |
Correct |
3 ms |
22864 KB |
Output is correct |
52 |
Correct |
3 ms |
22864 KB |
Output is correct |
53 |
Correct |
8 ms |
82468 KB |
Output is correct |
54 |
Correct |
9 ms |
82512 KB |
Output is correct |
55 |
Correct |
5 ms |
45392 KB |
Output is correct |
56 |
Correct |
8 ms |
82512 KB |
Output is correct |
57 |
Correct |
10 ms |
82512 KB |
Output is correct |
58 |
Execution timed out |
1059 ms |
22856 KB |
Time limit exceeded |
59 |
Halted |
0 ms |
0 KB |
- |