Submission #712956

# Submission time Handle Problem Language Result Execution time Memory
712956 2023-03-20T16:07:15 Z t6twotwo Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 13976 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
vector<int> H, lg;
vector<vector<int>> st;
int query(int l, int r) {
    int k = __lg(r - l);
    return max(st[l][k], st[r - (1 << k)][k]);
}
void init(int _N, vector<int> _H) {
    N = _N;
    H = _H;
    int lg = __lg(N);
    st.assign(N, vector<int>(lg + 1));
    for (int i = 0; i < N; i++) {
        st[i][0] = H[i];
    }
    for (int j = 0; j < lg; j++) {
        for (int i = 0; i + (2 << j) <= N; i++) {
            st[i][j + 1] = max(st[i][j], st[i + (1 << j)][j]);
        }
    }
}
int max_towers(int L, int R, int D) {
    R++;
    vector<int> p(R - L);
    iota(p.begin(), p.end(), L);
    sort(p.begin(), p.end(), [&](int i, int j) {
        return H[i] < H[j];
    });
    set<int> s;
    int ans = 0;
    for (int i : p) {
        auto it = s.lower_bound(i);
        if (it != s.begin()) {
            int j = *prev(it);
            if (max(H[i], H[j]) > query(j, i + 1) - D) continue;
        }
        if (it != s.end()) {
            int j = *it;
            if (max(H[i], H[j]) > query(i, j + 1) - D) continue;
        }
        ans++;
        s.insert(i);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 7176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 464 KB Output is correct
22 Correct 1 ms 464 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 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 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 1 ms 208 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 464 KB Output is correct
22 Correct 1 ms 464 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 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 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 20 ms 7708 KB Output is correct
37 Correct 35 ms 11532 KB Output is correct
38 Correct 36 ms 11552 KB Output is correct
39 Correct 35 ms 11592 KB Output is correct
40 Correct 31 ms 11568 KB Output is correct
41 Correct 61 ms 12364 KB Output is correct
42 Correct 29 ms 11536 KB Output is correct
43 Correct 31 ms 11592 KB Output is correct
44 Correct 29 ms 11584 KB Output is correct
45 Correct 30 ms 11548 KB Output is correct
46 Correct 29 ms 11592 KB Output is correct
47 Correct 42 ms 11936 KB Output is correct
48 Correct 43 ms 11820 KB Output is correct
49 Correct 34 ms 11544 KB Output is correct
50 Correct 40 ms 11548 KB Output is correct
51 Correct 35 ms 11564 KB Output is correct
52 Correct 71 ms 13200 KB Output is correct
53 Correct 74 ms 13916 KB Output is correct
54 Correct 84 ms 13940 KB Output is correct
55 Correct 31 ms 11636 KB Output is correct
56 Correct 40 ms 11536 KB Output is correct
57 Correct 57 ms 11808 KB Output is correct
58 Correct 61 ms 12480 KB Output is correct
59 Correct 67 ms 12688 KB Output is correct
60 Correct 75 ms 13976 KB Output is correct
61 Correct 69 ms 13604 KB Output is correct
62 Correct 72 ms 12900 KB Output is correct
63 Correct 71 ms 13592 KB Output is correct
64 Correct 33 ms 11544 KB Output is correct
65 Correct 31 ms 11556 KB Output is correct
66 Correct 31 ms 11600 KB Output is correct
67 Correct 31 ms 11640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4080 ms 13124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4017 ms 3592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 420 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 428 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 464 KB Output is correct
22 Correct 1 ms 464 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 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 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 20 ms 7708 KB Output is correct
37 Correct 35 ms 11532 KB Output is correct
38 Correct 36 ms 11552 KB Output is correct
39 Correct 35 ms 11592 KB Output is correct
40 Correct 31 ms 11568 KB Output is correct
41 Correct 61 ms 12364 KB Output is correct
42 Correct 29 ms 11536 KB Output is correct
43 Correct 31 ms 11592 KB Output is correct
44 Correct 29 ms 11584 KB Output is correct
45 Correct 30 ms 11548 KB Output is correct
46 Correct 29 ms 11592 KB Output is correct
47 Correct 42 ms 11936 KB Output is correct
48 Correct 43 ms 11820 KB Output is correct
49 Correct 34 ms 11544 KB Output is correct
50 Correct 40 ms 11548 KB Output is correct
51 Correct 35 ms 11564 KB Output is correct
52 Correct 71 ms 13200 KB Output is correct
53 Correct 74 ms 13916 KB Output is correct
54 Correct 84 ms 13940 KB Output is correct
55 Correct 31 ms 11636 KB Output is correct
56 Correct 40 ms 11536 KB Output is correct
57 Correct 57 ms 11808 KB Output is correct
58 Correct 61 ms 12480 KB Output is correct
59 Correct 67 ms 12688 KB Output is correct
60 Correct 75 ms 13976 KB Output is correct
61 Correct 69 ms 13604 KB Output is correct
62 Correct 72 ms 12900 KB Output is correct
63 Correct 71 ms 13592 KB Output is correct
64 Correct 33 ms 11544 KB Output is correct
65 Correct 31 ms 11556 KB Output is correct
66 Correct 31 ms 11600 KB Output is correct
67 Correct 31 ms 11640 KB Output is correct
68 Execution timed out 4080 ms 13124 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4043 ms 7176 KB Time limit exceeded
2 Halted 0 ms 0 KB -