# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
709749 |
2023-03-14T11:27:10 Z |
KoD |
Radio Towers (IOI22_towers) |
C++17 |
|
4000 ms |
11332 KB |
#include "towers.h"
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <limits>
#include <iterator>
#include <tuple>
namespace kod {
using std::vector;
using std::cerr;
using std::endl;
using std::begin;
using std::end;
using std::pair;
using std::tuple;
template <class F>
struct make_fixed : private F {
explicit make_fixed(F&& f) : F(std::forward<F>(f)) {}
template <class... Args> decltype(auto) operator()(Args&&... args) const {
return F::operator()(*this, std::forward<Args>(args)...);
}
};
int N;
vector<int> H;
int solve(int L, int R, int D) {
const int M = R - L + 1;
const auto A = H.begin() + L;
vector<int> par(M, -1), stack;
vector<vector<int>> child(M);
for (int i = 0; i < M; ++i) {
int j = -1;
while (!stack.empty() and A[stack.back()] < A[i]) {
j = stack.back();
stack.pop_back();
}
if (j != -1) par[j] = i;
if (!stack.empty()) par[i] = stack.back();
stack.push_back(i);
}
int root = -1;
for (int i = 0; i < M; ++i) {
if (par[i] == -1) root = i;
else child[par[i]].push_back(i);
}
const int ret = make_fixed([&](auto&& dfs, const int u) -> pair<int, int> {
int sum = 0, min = A[u];
for (const int v : child[u]) {
const auto [s, mi] = dfs(v);
sum += std::max(s, A[u] - mi >= D ? 1 : 0);
min = std::min(min, mi);
}
return {sum, min};
})(root).first;
return std::max(ret, 1);
}
}
void init(int N, std::vector<int> H) {
kod::N = N;
kod::H = H;
// kod::init();
}
int max_towers(int L, int R, int D) {
return kod::solve(L, R, D);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4030 ms |
6272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
464 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
464 KB |
Output is correct |
33 |
Correct |
1 ms |
464 KB |
Output is correct |
34 |
Correct |
1 ms |
464 KB |
Output is correct |
35 |
Correct |
1 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
464 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
464 KB |
Output is correct |
33 |
Correct |
1 ms |
464 KB |
Output is correct |
34 |
Correct |
1 ms |
464 KB |
Output is correct |
35 |
Correct |
1 ms |
464 KB |
Output is correct |
36 |
Correct |
11 ms |
1688 KB |
Output is correct |
37 |
Correct |
15 ms |
2708 KB |
Output is correct |
38 |
Correct |
12 ms |
1680 KB |
Output is correct |
39 |
Correct |
13 ms |
2448 KB |
Output is correct |
40 |
Correct |
13 ms |
1600 KB |
Output is correct |
41 |
Correct |
17 ms |
4620 KB |
Output is correct |
42 |
Correct |
10 ms |
1436 KB |
Output is correct |
43 |
Correct |
23 ms |
6080 KB |
Output is correct |
44 |
Correct |
12 ms |
2452 KB |
Output is correct |
45 |
Correct |
16 ms |
1560 KB |
Output is correct |
46 |
Correct |
12 ms |
1352 KB |
Output is correct |
47 |
Correct |
15 ms |
2696 KB |
Output is correct |
48 |
Correct |
12 ms |
1932 KB |
Output is correct |
49 |
Correct |
11 ms |
1352 KB |
Output is correct |
50 |
Correct |
14 ms |
3348 KB |
Output is correct |
51 |
Correct |
13 ms |
4928 KB |
Output is correct |
52 |
Correct |
23 ms |
5824 KB |
Output is correct |
53 |
Correct |
27 ms |
5252 KB |
Output is correct |
54 |
Correct |
20 ms |
5268 KB |
Output is correct |
55 |
Correct |
19 ms |
11288 KB |
Output is correct |
56 |
Correct |
21 ms |
10632 KB |
Output is correct |
57 |
Correct |
23 ms |
5664 KB |
Output is correct |
58 |
Correct |
22 ms |
5928 KB |
Output is correct |
59 |
Correct |
22 ms |
5780 KB |
Output is correct |
60 |
Correct |
21 ms |
5276 KB |
Output is correct |
61 |
Correct |
19 ms |
5256 KB |
Output is correct |
62 |
Correct |
19 ms |
5300 KB |
Output is correct |
63 |
Correct |
20 ms |
5264 KB |
Output is correct |
64 |
Correct |
21 ms |
10900 KB |
Output is correct |
65 |
Correct |
23 ms |
11332 KB |
Output is correct |
66 |
Correct |
20 ms |
9368 KB |
Output is correct |
67 |
Correct |
21 ms |
11072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4005 ms |
6164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4049 ms |
1616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
292 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
464 KB |
Output is correct |
24 |
Correct |
1 ms |
464 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
464 KB |
Output is correct |
33 |
Correct |
1 ms |
464 KB |
Output is correct |
34 |
Correct |
1 ms |
464 KB |
Output is correct |
35 |
Correct |
1 ms |
464 KB |
Output is correct |
36 |
Correct |
11 ms |
1688 KB |
Output is correct |
37 |
Correct |
15 ms |
2708 KB |
Output is correct |
38 |
Correct |
12 ms |
1680 KB |
Output is correct |
39 |
Correct |
13 ms |
2448 KB |
Output is correct |
40 |
Correct |
13 ms |
1600 KB |
Output is correct |
41 |
Correct |
17 ms |
4620 KB |
Output is correct |
42 |
Correct |
10 ms |
1436 KB |
Output is correct |
43 |
Correct |
23 ms |
6080 KB |
Output is correct |
44 |
Correct |
12 ms |
2452 KB |
Output is correct |
45 |
Correct |
16 ms |
1560 KB |
Output is correct |
46 |
Correct |
12 ms |
1352 KB |
Output is correct |
47 |
Correct |
15 ms |
2696 KB |
Output is correct |
48 |
Correct |
12 ms |
1932 KB |
Output is correct |
49 |
Correct |
11 ms |
1352 KB |
Output is correct |
50 |
Correct |
14 ms |
3348 KB |
Output is correct |
51 |
Correct |
13 ms |
4928 KB |
Output is correct |
52 |
Correct |
23 ms |
5824 KB |
Output is correct |
53 |
Correct |
27 ms |
5252 KB |
Output is correct |
54 |
Correct |
20 ms |
5268 KB |
Output is correct |
55 |
Correct |
19 ms |
11288 KB |
Output is correct |
56 |
Correct |
21 ms |
10632 KB |
Output is correct |
57 |
Correct |
23 ms |
5664 KB |
Output is correct |
58 |
Correct |
22 ms |
5928 KB |
Output is correct |
59 |
Correct |
22 ms |
5780 KB |
Output is correct |
60 |
Correct |
21 ms |
5276 KB |
Output is correct |
61 |
Correct |
19 ms |
5256 KB |
Output is correct |
62 |
Correct |
19 ms |
5300 KB |
Output is correct |
63 |
Correct |
20 ms |
5264 KB |
Output is correct |
64 |
Correct |
21 ms |
10900 KB |
Output is correct |
65 |
Correct |
23 ms |
11332 KB |
Output is correct |
66 |
Correct |
20 ms |
9368 KB |
Output is correct |
67 |
Correct |
21 ms |
11072 KB |
Output is correct |
68 |
Execution timed out |
4005 ms |
6164 KB |
Time limit exceeded |
69 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4030 ms |
6272 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |