답안 #667085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
667085 2022-11-30T11:13:20 Z tatyam 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 12048 KB
#include <bits/stdc++.h>
using namespace std;
template<class T> void chmax(T& a, T b){ if(a < b) a = b; }


int N;
vector<int> H;
vector<pair<int, int>> seg;
void init(int N, vector<int> H) {
    ::N = N;
    ::H = H;
    seg.resize(N * 2);
    for(int i = 0; i < N; i++) seg[N + i] = {H[i], i};
    for(int i = N; --i; ){
        seg[i] = max(seg[i << 1], seg[i << 1 | 1]);
    }
}
int argmax(int L, int R){
    L += N;
    R += N;
    pair<int, int> ans;
    while(L < R){
        if(L & 1) chmax(ans, seg[L++]);
        if(R & 1) chmax(ans, seg[--R]);
        L >>= 1; R >>= 1;
    }
    return ans.second;
}

int max_towers(int L, int R, int D) {
    auto dfs = [&](int L, int R, auto dfs) -> pair<int, int> {
        if(R - L == 0) return {0, INT_MAX};
        const int mid = argmax(L, R);
        const int x = H[mid];
        auto [c1, mn1] = dfs(L, mid, dfs);
        auto [c2, mn2] = dfs(mid + 1, R, dfs);
        if(c1 <= 1 && c2 <= 1){
            if(x - max(mn1, mn2) >= D) return {2, 0};
            return {1, min({mn1, mn2, x})};
        }
        if(c1 < c2){
            swap(c1, c2);
            swap(mn1, mn2);
        }
        if(c2 <= 1) return {c1 + (x - mn2 >= D), 0};
        return {c1 + c2, 0};
    };
    return dfs(L, R + 1, dfs).first;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4018 ms 6376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 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 2 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 288 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 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 2 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 288 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 9 ms 2000 KB Output is correct
37 Correct 13 ms 2984 KB Output is correct
38 Correct 13 ms 2984 KB Output is correct
39 Correct 20 ms 2972 KB Output is correct
40 Correct 12 ms 2976 KB Output is correct
41 Correct 21 ms 2972 KB Output is correct
42 Correct 20 ms 3016 KB Output is correct
43 Correct 24 ms 7360 KB Output is correct
44 Correct 14 ms 3912 KB Output is correct
45 Correct 14 ms 3016 KB Output is correct
46 Correct 18 ms 2988 KB Output is correct
47 Correct 14 ms 3016 KB Output is correct
48 Correct 12 ms 2960 KB Output is correct
49 Correct 21 ms 2996 KB Output is correct
50 Correct 13 ms 4672 KB Output is correct
51 Correct 23 ms 6172 KB Output is correct
52 Correct 15 ms 2976 KB Output is correct
53 Correct 15 ms 2968 KB Output is correct
54 Correct 22 ms 3016 KB Output is correct
55 Correct 23 ms 11944 KB Output is correct
56 Correct 22 ms 11072 KB Output is correct
57 Correct 15 ms 2848 KB Output is correct
58 Correct 16 ms 3016 KB Output is correct
59 Correct 20 ms 2968 KB Output is correct
60 Correct 15 ms 2968 KB Output is correct
61 Correct 16 ms 2968 KB Output is correct
62 Correct 16 ms 2976 KB Output is correct
63 Correct 16 ms 2956 KB Output is correct
64 Correct 30 ms 12048 KB Output is correct
65 Correct 23 ms 11976 KB Output is correct
66 Correct 21 ms 8256 KB Output is correct
67 Correct 23 ms 11428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4019 ms 3016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4002 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 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 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 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 2 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 288 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 9 ms 2000 KB Output is correct
37 Correct 13 ms 2984 KB Output is correct
38 Correct 13 ms 2984 KB Output is correct
39 Correct 20 ms 2972 KB Output is correct
40 Correct 12 ms 2976 KB Output is correct
41 Correct 21 ms 2972 KB Output is correct
42 Correct 20 ms 3016 KB Output is correct
43 Correct 24 ms 7360 KB Output is correct
44 Correct 14 ms 3912 KB Output is correct
45 Correct 14 ms 3016 KB Output is correct
46 Correct 18 ms 2988 KB Output is correct
47 Correct 14 ms 3016 KB Output is correct
48 Correct 12 ms 2960 KB Output is correct
49 Correct 21 ms 2996 KB Output is correct
50 Correct 13 ms 4672 KB Output is correct
51 Correct 23 ms 6172 KB Output is correct
52 Correct 15 ms 2976 KB Output is correct
53 Correct 15 ms 2968 KB Output is correct
54 Correct 22 ms 3016 KB Output is correct
55 Correct 23 ms 11944 KB Output is correct
56 Correct 22 ms 11072 KB Output is correct
57 Correct 15 ms 2848 KB Output is correct
58 Correct 16 ms 3016 KB Output is correct
59 Correct 20 ms 2968 KB Output is correct
60 Correct 15 ms 2968 KB Output is correct
61 Correct 16 ms 2968 KB Output is correct
62 Correct 16 ms 2976 KB Output is correct
63 Correct 16 ms 2956 KB Output is correct
64 Correct 30 ms 12048 KB Output is correct
65 Correct 23 ms 11976 KB Output is correct
66 Correct 21 ms 8256 KB Output is correct
67 Correct 23 ms 11428 KB Output is correct
68 Execution timed out 4019 ms 3016 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4018 ms 6376 KB Time limit exceeded
2 Halted 0 ms 0 KB -