답안 #776871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776871 2023-07-08T10:57:48 Z alexander707070 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 11940 KB
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;

int n,h[MAXN],maxh,num;
int dp[MAXN],ans;

pair<int,int> tree[4*MAXN];
int mins[4*MAXN];

pair<int,int> combine(pair<int,int> fr,pair<int,int> sc){
    if(fr.first>sc.first)return fr;
    return sc;
}

void build(int v,int l,int r){
    if(l==r){
        tree[v]={h[l],l};
        mins[v]=h[l];
    }else{
        int tt=(l+r)/2;
        build(2*v,l,tt);
        build(2*v+1,tt+1,r);
        tree[v]=combine(tree[2*v],tree[2*v+1]);
        mins[v]=min(mins[2*v],mins[2*v+1]);
    }
}

pair<int,int> best(int v,int l,int r,int ll,int rr){
    if(ll>rr)return {-1,0};
    if(l==ll and r==rr){
        return tree[v];
    }else{
        int tt=(l+r)/2;
        return combine( best(2*v,l,tt,ll,min(tt,rr)) , best(2*v+1,tt+1,r,max(tt+1,ll),rr) );
    }
}

int minh(int v,int l,int r,int ll,int rr){
    if(ll>rr)return 1000000000;
    if(l==ll and r==rr){
        return mins[v];
    }else{
        int tt=(l+r)/2;
        return min( minh(2*v,l,tt,ll,min(tt,rr)) , minh(2*v+1,tt+1,r,max(tt+1,ll),rr) );
    }
}

void init(int N,vector<int> H){
    n=N;
    for(int i=1;i<=n;i++){
        h[i]=H[i-1];
    }
    build(1,1,n);
}

int solve(int l,int r,int maxh,int d){
    if(l>r)return 0;

    int pos=best(1,1,n,l,r).second;

    int z=0;
    if(minh(1,1,n,l,r)<=maxh)z=1;

    return max(z, solve(l,pos-1,h[pos]-d,d)+solve(pos+1,r,h[pos]-d,d) );
}

int max_towers(int L, int R, int D){
    L++; R++;
    return solve(L,R,1000000000,D);
}

/*
int main(){
    init(7, {10, 20, 60, 40, 50, 30, 70});
    cout<<max_towers(1,5,10)<<"\n";
    cout<<max_towers(0, 6, 17)<<"\n";
}
*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4091 ms 6044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 1 ms 464 KB Output is correct
24 Correct 1 ms 484 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 376 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 308 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 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 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 1 ms 464 KB Output is correct
24 Correct 1 ms 484 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 376 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 308 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 12 ms 2604 KB Output is correct
37 Correct 27 ms 4424 KB Output is correct
38 Correct 14 ms 4520 KB Output is correct
39 Correct 19 ms 4504 KB Output is correct
40 Correct 13 ms 4560 KB Output is correct
41 Correct 33 ms 4532 KB Output is correct
42 Correct 18 ms 4424 KB Output is correct
43 Correct 31 ms 8092 KB Output is correct
44 Correct 18 ms 5152 KB Output is correct
45 Correct 16 ms 4520 KB Output is correct
46 Correct 13 ms 4520 KB Output is correct
47 Correct 20 ms 4516 KB Output is correct
48 Correct 23 ms 4432 KB Output is correct
49 Correct 12 ms 4504 KB Output is correct
50 Correct 18 ms 5824 KB Output is correct
51 Correct 27 ms 7100 KB Output is correct
52 Correct 38 ms 4560 KB Output is correct
53 Correct 37 ms 4516 KB Output is correct
54 Correct 37 ms 4560 KB Output is correct
55 Correct 34 ms 11928 KB Output is correct
56 Correct 43 ms 11228 KB Output is correct
57 Correct 39 ms 4516 KB Output is correct
58 Correct 37 ms 4516 KB Output is correct
59 Correct 39 ms 4504 KB Output is correct
60 Correct 44 ms 4536 KB Output is correct
61 Correct 37 ms 4524 KB Output is correct
62 Correct 39 ms 4560 KB Output is correct
63 Correct 44 ms 4424 KB Output is correct
64 Correct 37 ms 11928 KB Output is correct
65 Correct 34 ms 11940 KB Output is correct
66 Correct 42 ms 8928 KB Output is correct
67 Correct 36 ms 11396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4029 ms 4520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4088 ms 1232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 1 ms 464 KB Output is correct
24 Correct 1 ms 484 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 376 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 308 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 12 ms 2604 KB Output is correct
37 Correct 27 ms 4424 KB Output is correct
38 Correct 14 ms 4520 KB Output is correct
39 Correct 19 ms 4504 KB Output is correct
40 Correct 13 ms 4560 KB Output is correct
41 Correct 33 ms 4532 KB Output is correct
42 Correct 18 ms 4424 KB Output is correct
43 Correct 31 ms 8092 KB Output is correct
44 Correct 18 ms 5152 KB Output is correct
45 Correct 16 ms 4520 KB Output is correct
46 Correct 13 ms 4520 KB Output is correct
47 Correct 20 ms 4516 KB Output is correct
48 Correct 23 ms 4432 KB Output is correct
49 Correct 12 ms 4504 KB Output is correct
50 Correct 18 ms 5824 KB Output is correct
51 Correct 27 ms 7100 KB Output is correct
52 Correct 38 ms 4560 KB Output is correct
53 Correct 37 ms 4516 KB Output is correct
54 Correct 37 ms 4560 KB Output is correct
55 Correct 34 ms 11928 KB Output is correct
56 Correct 43 ms 11228 KB Output is correct
57 Correct 39 ms 4516 KB Output is correct
58 Correct 37 ms 4516 KB Output is correct
59 Correct 39 ms 4504 KB Output is correct
60 Correct 44 ms 4536 KB Output is correct
61 Correct 37 ms 4524 KB Output is correct
62 Correct 39 ms 4560 KB Output is correct
63 Correct 44 ms 4424 KB Output is correct
64 Correct 37 ms 11928 KB Output is correct
65 Correct 34 ms 11940 KB Output is correct
66 Correct 42 ms 8928 KB Output is correct
67 Correct 36 ms 11396 KB Output is correct
68 Execution timed out 4029 ms 4520 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4091 ms 6044 KB Time limit exceeded
2 Halted 0 ms 0 KB -