Submission #1067270

# Submission time Handle Problem Language Result Execution time Memory
1067270 2024-08-20T13:47:24 Z n1k Radio Towers (IOI22_towers) C++17
11 / 100
4000 ms 8892 KB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> h;

void init(int N, std::vector<int> H) {
	n = N;
	h = H;
}

int getmin(int l, int r){
	array<int, 2> mn={int(1e9) + 10, 0};
	for(int i=l; i<=r; i++) mn = min(mn, {h[i], i});
	return mn[0];
}

int find(int l, int r, int d, long long minh){
	if(l>r) return 0;
	array<int, 2> mx = {0};
	for(int i=l; i<=r; i++){
		mx = max(mx, {h[i], i});
	}

	int ret = max({
		int(mx[0]+d<=minh), 
		find(l, mx[1]-1, d, mx[0]) + find(mx[1] + 1, r, d, mx[0]),
		int(getmin(l, mx[1]-1)+d<=minh),
		int(getmin(mx[1]+1, r)+d<=minh)
	});
	return ret;
}

int max_towers(int L, int R, int D) {
	return find(L, R, D, 1e18);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4057 ms 4528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 4 ms 600 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 4 ms 600 KB Output is correct
33 Correct 5 ms 600 KB Output is correct
34 Correct 4 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 4 ms 600 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 4 ms 600 KB Output is correct
33 Correct 5 ms 600 KB Output is correct
34 Correct 4 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 10 ms 1112 KB Output is correct
37 Correct 10 ms 1368 KB Output is correct
38 Correct 9 ms 1592 KB Output is correct
39 Correct 17 ms 1604 KB Output is correct
40 Correct 11 ms 1368 KB Output is correct
41 Correct 12 ms 1448 KB Output is correct
42 Correct 9 ms 1368 KB Output is correct
43 Correct 2163 ms 5108 KB Output is correct
44 Correct 188 ms 2248 KB Output is correct
45 Correct 13 ms 1368 KB Output is correct
46 Correct 13 ms 1600 KB Output is correct
47 Correct 10 ms 1368 KB Output is correct
48 Correct 9 ms 1452 KB Output is correct
49 Correct 10 ms 1364 KB Output is correct
50 Correct 472 ms 2904 KB Output is correct
51 Correct 1288 ms 4040 KB Output is correct
52 Correct 14 ms 1368 KB Output is correct
53 Correct 20 ms 1596 KB Output is correct
54 Correct 13 ms 1368 KB Output is correct
55 Execution timed out 4080 ms 8892 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4100 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4013 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 4 ms 600 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 4 ms 600 KB Output is correct
33 Correct 5 ms 600 KB Output is correct
34 Correct 4 ms 344 KB Output is correct
35 Correct 3 ms 344 KB Output is correct
36 Correct 10 ms 1112 KB Output is correct
37 Correct 10 ms 1368 KB Output is correct
38 Correct 9 ms 1592 KB Output is correct
39 Correct 17 ms 1604 KB Output is correct
40 Correct 11 ms 1368 KB Output is correct
41 Correct 12 ms 1448 KB Output is correct
42 Correct 9 ms 1368 KB Output is correct
43 Correct 2163 ms 5108 KB Output is correct
44 Correct 188 ms 2248 KB Output is correct
45 Correct 13 ms 1368 KB Output is correct
46 Correct 13 ms 1600 KB Output is correct
47 Correct 10 ms 1368 KB Output is correct
48 Correct 9 ms 1452 KB Output is correct
49 Correct 10 ms 1364 KB Output is correct
50 Correct 472 ms 2904 KB Output is correct
51 Correct 1288 ms 4040 KB Output is correct
52 Correct 14 ms 1368 KB Output is correct
53 Correct 20 ms 1596 KB Output is correct
54 Correct 13 ms 1368 KB Output is correct
55 Execution timed out 4080 ms 8892 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4057 ms 4528 KB Time limit exceeded
2 Halted 0 ms 0 KB -