Submission #1083684

# Submission time Handle Problem Language Result Execution time Memory
1083684 2024-09-03T20:08:38 Z xnqs K blocks (IZhO14_blocks) C++17
53 / 100
1000 ms 42428 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <cstring>
 
int x, k;
int arr[100005];
int dp[105][100005];
 
void divide(int l, int r, int optl, int optr, int idx) {
	//std::cerr << " " << l << " " << r << " " << optl << " " << optr << " " << idx << "\n";
	if (l>r) {
		return;
	}
 
	int m = (l+r)>>1;
	int max = 0;
	int opt = -1;
	for (int i = std::min(m, optr+100); i >= std::max(1, optl-100); i--) {
		max = std::max(max, arr[i]);
		if (dp[idx][m] > dp[idx-1][i-1]+max) {
			dp[idx][m] = dp[idx-1][i-1]+max;
			opt = i;
		}
	}
 
	divide(l,m-1,optl,opt,idx);
	divide(m+1,r,opt,optr,idx);
}
 
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
 
	std::cin >> x >> k;
	for (int i = 1; i <= x; i++) {
		std::cin >> arr[i];
	}
 
	memset(dp,0x3f,sizeof(dp));
	dp[1][0] = 0;
	for (int i = 1; i <= x; i++) {
		dp[1][i] = std::max(dp[1][i-1], arr[i]);
	}
	dp[1][0] = 0x3f3f3f3f;
	for (int i = 2; i <= k; i++) {
		divide(1,x,1,x,i);
	}
 
	std::cout << dp[k][x] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 41560 KB Output is correct
2 Correct 13 ms 41564 KB Output is correct
3 Correct 14 ms 41560 KB Output is correct
4 Correct 15 ms 41564 KB Output is correct
5 Correct 15 ms 41564 KB Output is correct
6 Correct 14 ms 41564 KB Output is correct
7 Correct 15 ms 41564 KB Output is correct
8 Correct 14 ms 41560 KB Output is correct
9 Correct 14 ms 41564 KB Output is correct
10 Correct 14 ms 41564 KB Output is correct
11 Correct 14 ms 41560 KB Output is correct
12 Correct 14 ms 41496 KB Output is correct
13 Correct 14 ms 41564 KB Output is correct
14 Correct 14 ms 41564 KB Output is correct
15 Correct 15 ms 41592 KB Output is correct
16 Correct 12 ms 41564 KB Output is correct
17 Correct 13 ms 41564 KB Output is correct
18 Correct 14 ms 41568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 41564 KB Output is correct
2 Correct 13 ms 41492 KB Output is correct
3 Correct 13 ms 41560 KB Output is correct
4 Correct 15 ms 41564 KB Output is correct
5 Correct 14 ms 41504 KB Output is correct
6 Correct 15 ms 41564 KB Output is correct
7 Correct 14 ms 41564 KB Output is correct
8 Correct 13 ms 41564 KB Output is correct
9 Correct 14 ms 41564 KB Output is correct
10 Correct 14 ms 41564 KB Output is correct
11 Correct 15 ms 41564 KB Output is correct
12 Correct 12 ms 41620 KB Output is correct
13 Correct 15 ms 41564 KB Output is correct
14 Correct 14 ms 41560 KB Output is correct
15 Correct 14 ms 41564 KB Output is correct
16 Correct 17 ms 41564 KB Output is correct
17 Correct 13 ms 41448 KB Output is correct
18 Correct 15 ms 41564 KB Output is correct
19 Correct 15 ms 41564 KB Output is correct
20 Correct 14 ms 41564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 41560 KB Output is correct
2 Correct 13 ms 41564 KB Output is correct
3 Correct 14 ms 41560 KB Output is correct
4 Correct 15 ms 41564 KB Output is correct
5 Correct 15 ms 41564 KB Output is correct
6 Correct 14 ms 41564 KB Output is correct
7 Correct 15 ms 41564 KB Output is correct
8 Correct 14 ms 41560 KB Output is correct
9 Correct 14 ms 41564 KB Output is correct
10 Correct 14 ms 41564 KB Output is correct
11 Correct 14 ms 41560 KB Output is correct
12 Correct 14 ms 41496 KB Output is correct
13 Correct 14 ms 41564 KB Output is correct
14 Correct 14 ms 41564 KB Output is correct
15 Correct 15 ms 41592 KB Output is correct
16 Correct 12 ms 41564 KB Output is correct
17 Correct 13 ms 41564 KB Output is correct
18 Correct 14 ms 41568 KB Output is correct
19 Correct 14 ms 41564 KB Output is correct
20 Correct 13 ms 41492 KB Output is correct
21 Correct 13 ms 41560 KB Output is correct
22 Correct 15 ms 41564 KB Output is correct
23 Correct 14 ms 41504 KB Output is correct
24 Correct 15 ms 41564 KB Output is correct
25 Correct 14 ms 41564 KB Output is correct
26 Correct 13 ms 41564 KB Output is correct
27 Correct 14 ms 41564 KB Output is correct
28 Correct 14 ms 41564 KB Output is correct
29 Correct 15 ms 41564 KB Output is correct
30 Correct 12 ms 41620 KB Output is correct
31 Correct 15 ms 41564 KB Output is correct
32 Correct 14 ms 41560 KB Output is correct
33 Correct 14 ms 41564 KB Output is correct
34 Correct 17 ms 41564 KB Output is correct
35 Correct 13 ms 41448 KB Output is correct
36 Correct 15 ms 41564 KB Output is correct
37 Correct 15 ms 41564 KB Output is correct
38 Correct 14 ms 41564 KB Output is correct
39 Correct 14 ms 41564 KB Output is correct
40 Correct 13 ms 41564 KB Output is correct
41 Correct 14 ms 41512 KB Output is correct
42 Correct 13 ms 41564 KB Output is correct
43 Correct 14 ms 41564 KB Output is correct
44 Correct 14 ms 41616 KB Output is correct
45 Correct 13 ms 41564 KB Output is correct
46 Correct 13 ms 41664 KB Output is correct
47 Correct 14 ms 41564 KB Output is correct
48 Correct 14 ms 41544 KB Output is correct
49 Correct 15 ms 41564 KB Output is correct
50 Correct 14 ms 41564 KB Output is correct
51 Correct 13 ms 41664 KB Output is correct
52 Correct 14 ms 41564 KB Output is correct
53 Correct 14 ms 41564 KB Output is correct
54 Correct 15 ms 41564 KB Output is correct
55 Correct 16 ms 41560 KB Output is correct
56 Correct 14 ms 41472 KB Output is correct
57 Correct 14 ms 41528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 41560 KB Output is correct
2 Correct 13 ms 41564 KB Output is correct
3 Correct 14 ms 41560 KB Output is correct
4 Correct 15 ms 41564 KB Output is correct
5 Correct 15 ms 41564 KB Output is correct
6 Correct 14 ms 41564 KB Output is correct
7 Correct 15 ms 41564 KB Output is correct
8 Correct 14 ms 41560 KB Output is correct
9 Correct 14 ms 41564 KB Output is correct
10 Correct 14 ms 41564 KB Output is correct
11 Correct 14 ms 41560 KB Output is correct
12 Correct 14 ms 41496 KB Output is correct
13 Correct 14 ms 41564 KB Output is correct
14 Correct 14 ms 41564 KB Output is correct
15 Correct 15 ms 41592 KB Output is correct
16 Correct 12 ms 41564 KB Output is correct
17 Correct 13 ms 41564 KB Output is correct
18 Correct 14 ms 41568 KB Output is correct
19 Correct 14 ms 41564 KB Output is correct
20 Correct 13 ms 41492 KB Output is correct
21 Correct 13 ms 41560 KB Output is correct
22 Correct 15 ms 41564 KB Output is correct
23 Correct 14 ms 41504 KB Output is correct
24 Correct 15 ms 41564 KB Output is correct
25 Correct 14 ms 41564 KB Output is correct
26 Correct 13 ms 41564 KB Output is correct
27 Correct 14 ms 41564 KB Output is correct
28 Correct 14 ms 41564 KB Output is correct
29 Correct 15 ms 41564 KB Output is correct
30 Correct 12 ms 41620 KB Output is correct
31 Correct 15 ms 41564 KB Output is correct
32 Correct 14 ms 41560 KB Output is correct
33 Correct 14 ms 41564 KB Output is correct
34 Correct 17 ms 41564 KB Output is correct
35 Correct 13 ms 41448 KB Output is correct
36 Correct 15 ms 41564 KB Output is correct
37 Correct 15 ms 41564 KB Output is correct
38 Correct 14 ms 41564 KB Output is correct
39 Correct 14 ms 41564 KB Output is correct
40 Correct 13 ms 41564 KB Output is correct
41 Correct 14 ms 41512 KB Output is correct
42 Correct 13 ms 41564 KB Output is correct
43 Correct 14 ms 41564 KB Output is correct
44 Correct 14 ms 41616 KB Output is correct
45 Correct 13 ms 41564 KB Output is correct
46 Correct 13 ms 41664 KB Output is correct
47 Correct 14 ms 41564 KB Output is correct
48 Correct 14 ms 41544 KB Output is correct
49 Correct 15 ms 41564 KB Output is correct
50 Correct 14 ms 41564 KB Output is correct
51 Correct 13 ms 41664 KB Output is correct
52 Correct 14 ms 41564 KB Output is correct
53 Correct 14 ms 41564 KB Output is correct
54 Correct 15 ms 41564 KB Output is correct
55 Correct 16 ms 41560 KB Output is correct
56 Correct 14 ms 41472 KB Output is correct
57 Correct 14 ms 41528 KB Output is correct
58 Correct 48 ms 41564 KB Output is correct
59 Correct 18 ms 41564 KB Output is correct
60 Correct 56 ms 41560 KB Output is correct
61 Correct 549 ms 41564 KB Output is correct
62 Execution timed out 1034 ms 42428 KB Time limit exceeded
63 Halted 0 ms 0 KB -