답안 #761502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
761502 2023-06-19T20:55:06 Z doowey 송신탑 (IOI22_towers) C++17
56 / 100
4000 ms 13912 KB
#include <bits/stdc++.h>
#include "towers.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair

const int N = (int)1e5 + 10;
const int LOG = 17;
int h[N];
int tab[LOG][N];
int n;


void init(int _n, vector<int> H) {
    n = _n;
    for(int i = 0 ; i < n; i ++ ){
        h[i] = H[i];
        tab[0][i] = h[i];
    }
    for(int ln = 1; ln < LOG; ln ++ ){
        for(int i = 0 ; i + (1 << ln) - 1 < n; i ++ ){
            tab[ln][i] = min(tab[ln-1][i], tab[ln-1][i + (1 << (ln - 1))]);
        }
    }
}

int D = -1;
int jump[LOG][N];

void compute_diff(int dd){
    if(D != dd){
        D = dd;
        for(int i = 0 ; i <= n; i ++ ){
            jump[0][i] = n;
        }
        int lf, rf;
        for(int c = 1; c + 1 < n; c ++ ){
            lf = c;
            rf = c;
            for(int ln = LOG - 1; ln >= 0 ; ln -- ){
                if(lf - (1 << ln) >= 0 && tab[ln][lf - (1 << ln)] > h[c] - dd){
                    lf -= (1 << ln);
                }
                if(rf + (1 << ln) < n && tab[ln][rf + 1] > h[c] - dd){
                    rf += (1 << ln);
                }
            }
            lf -- ;
            rf ++ ;
            if(lf < 0) continue;
            jump[0][lf] = min(jump[0][lf], rf);
        }
        for(int i = n - 1; i >= 0; i -- ){
            jump[0][i]=min(jump[0][i],jump[0][i+1]);
        }
        for(int l = 1; l < LOG; l ++ ){
            for(int i = 0 ; i <= n; i ++ ){
                jump[l][i]=jump[l-1][jump[l-1][i]];
            }
        }
    }
}
int max_towers(int L, int R, int delta) {
    compute_diff(delta);
    int res = 1;
    for(int ln = LOG - 1; ln >= 0 ; ln -- ){
        if(jump[ln][L] <= R){
            L=jump[ln][L];
            res += (1 << ln);
        }
    }
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 8292 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 592 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 592 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 15 ms 9008 KB Output is correct
37 Correct 31 ms 13792 KB Output is correct
38 Correct 26 ms 13804 KB Output is correct
39 Correct 25 ms 13788 KB Output is correct
40 Correct 25 ms 13808 KB Output is correct
41 Correct 25 ms 13876 KB Output is correct
42 Correct 24 ms 13856 KB Output is correct
43 Correct 24 ms 13808 KB Output is correct
44 Correct 32 ms 13872 KB Output is correct
45 Correct 24 ms 13856 KB Output is correct
46 Correct 25 ms 13888 KB Output is correct
47 Correct 24 ms 13812 KB Output is correct
48 Correct 29 ms 13876 KB Output is correct
49 Correct 24 ms 13804 KB Output is correct
50 Correct 25 ms 13800 KB Output is correct
51 Correct 24 ms 13908 KB Output is correct
52 Correct 24 ms 13856 KB Output is correct
53 Correct 24 ms 13808 KB Output is correct
54 Correct 29 ms 13888 KB Output is correct
55 Correct 25 ms 13856 KB Output is correct
56 Correct 26 ms 13796 KB Output is correct
57 Correct 25 ms 13480 KB Output is correct
58 Correct 26 ms 13880 KB Output is correct
59 Correct 25 ms 13856 KB Output is correct
60 Correct 24 ms 13852 KB Output is correct
61 Correct 24 ms 13856 KB Output is correct
62 Correct 25 ms 13796 KB Output is correct
63 Correct 24 ms 13864 KB Output is correct
64 Correct 24 ms 13896 KB Output is correct
65 Correct 25 ms 13864 KB Output is correct
66 Correct 28 ms 13876 KB Output is correct
67 Correct 26 ms 13872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 13756 KB Output is correct
2 Correct 755 ms 13864 KB Output is correct
3 Correct 538 ms 13788 KB Output is correct
4 Correct 610 ms 13892 KB Output is correct
5 Correct 734 ms 13888 KB Output is correct
6 Correct 420 ms 13844 KB Output is correct
7 Correct 725 ms 13852 KB Output is correct
8 Correct 665 ms 13820 KB Output is correct
9 Correct 794 ms 13856 KB Output is correct
10 Correct 672 ms 13876 KB Output is correct
11 Correct 839 ms 13872 KB Output is correct
12 Correct 700 ms 13880 KB Output is correct
13 Correct 625 ms 13860 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 25 ms 13872 KB Output is correct
18 Correct 23 ms 13840 KB Output is correct
19 Correct 24 ms 13880 KB Output is correct
20 Correct 24 ms 13788 KB Output is correct
21 Correct 24 ms 13860 KB Output is correct
22 Correct 24 ms 13872 KB Output is correct
23 Correct 23 ms 13888 KB Output is correct
24 Correct 24 ms 13896 KB Output is correct
25 Correct 27 ms 13912 KB Output is correct
26 Correct 30 ms 13856 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 592 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4098 ms 3552 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 592 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 1 ms 464 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 592 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 15 ms 9008 KB Output is correct
37 Correct 31 ms 13792 KB Output is correct
38 Correct 26 ms 13804 KB Output is correct
39 Correct 25 ms 13788 KB Output is correct
40 Correct 25 ms 13808 KB Output is correct
41 Correct 25 ms 13876 KB Output is correct
42 Correct 24 ms 13856 KB Output is correct
43 Correct 24 ms 13808 KB Output is correct
44 Correct 32 ms 13872 KB Output is correct
45 Correct 24 ms 13856 KB Output is correct
46 Correct 25 ms 13888 KB Output is correct
47 Correct 24 ms 13812 KB Output is correct
48 Correct 29 ms 13876 KB Output is correct
49 Correct 24 ms 13804 KB Output is correct
50 Correct 25 ms 13800 KB Output is correct
51 Correct 24 ms 13908 KB Output is correct
52 Correct 24 ms 13856 KB Output is correct
53 Correct 24 ms 13808 KB Output is correct
54 Correct 29 ms 13888 KB Output is correct
55 Correct 25 ms 13856 KB Output is correct
56 Correct 26 ms 13796 KB Output is correct
57 Correct 25 ms 13480 KB Output is correct
58 Correct 26 ms 13880 KB Output is correct
59 Correct 25 ms 13856 KB Output is correct
60 Correct 24 ms 13852 KB Output is correct
61 Correct 24 ms 13856 KB Output is correct
62 Correct 25 ms 13796 KB Output is correct
63 Correct 24 ms 13864 KB Output is correct
64 Correct 24 ms 13896 KB Output is correct
65 Correct 25 ms 13864 KB Output is correct
66 Correct 28 ms 13876 KB Output is correct
67 Correct 26 ms 13872 KB Output is correct
68 Correct 522 ms 13756 KB Output is correct
69 Correct 755 ms 13864 KB Output is correct
70 Correct 538 ms 13788 KB Output is correct
71 Correct 610 ms 13892 KB Output is correct
72 Correct 734 ms 13888 KB Output is correct
73 Correct 420 ms 13844 KB Output is correct
74 Correct 725 ms 13852 KB Output is correct
75 Correct 665 ms 13820 KB Output is correct
76 Correct 794 ms 13856 KB Output is correct
77 Correct 672 ms 13876 KB Output is correct
78 Correct 839 ms 13872 KB Output is correct
79 Correct 700 ms 13880 KB Output is correct
80 Correct 625 ms 13860 KB Output is correct
81 Correct 0 ms 336 KB Output is correct
82 Correct 1 ms 592 KB Output is correct
83 Correct 1 ms 592 KB Output is correct
84 Correct 25 ms 13872 KB Output is correct
85 Correct 23 ms 13840 KB Output is correct
86 Correct 24 ms 13880 KB Output is correct
87 Correct 24 ms 13788 KB Output is correct
88 Correct 24 ms 13860 KB Output is correct
89 Correct 24 ms 13872 KB Output is correct
90 Correct 23 ms 13888 KB Output is correct
91 Correct 24 ms 13896 KB Output is correct
92 Correct 27 ms 13912 KB Output is correct
93 Correct 30 ms 13856 KB Output is correct
94 Correct 1 ms 592 KB Output is correct
95 Correct 1 ms 592 KB Output is correct
96 Correct 1 ms 592 KB Output is correct
97 Correct 1 ms 592 KB Output is correct
98 Correct 1 ms 592 KB Output is correct
99 Correct 1 ms 592 KB Output is correct
100 Correct 1 ms 592 KB Output is correct
101 Correct 1 ms 592 KB Output is correct
102 Correct 1 ms 592 KB Output is correct
103 Correct 1 ms 592 KB Output is correct
104 Correct 740 ms 12340 KB Output is correct
105 Correct 636 ms 13888 KB Output is correct
106 Correct 694 ms 13872 KB Output is correct
107 Correct 745 ms 13872 KB Output is correct
108 Correct 620 ms 13860 KB Output is correct
109 Correct 608 ms 13788 KB Output is correct
110 Correct 811 ms 13852 KB Output is correct
111 Correct 746 ms 13888 KB Output is correct
112 Correct 708 ms 13896 KB Output is correct
113 Correct 638 ms 13860 KB Output is correct
114 Correct 780 ms 13892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 8292 KB Time limit exceeded
2 Halted 0 ms 0 KB -