답안 #1022990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022990 2024-07-14T08:29:33 Z vjudge1 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 17864 KB
#include "towers.h"
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define sz(s) (int)s.size()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>

const int MAX=2e5+10;
const int inf=1e9;

struct segtree{
    int mx[4*MAX],mn[4*MAX],pmx[4*MAX];

    void build(int v,int tl,int tr,vector<int> &H){
        if(tl==tr){
            mx[v]=mn[v]=H[tl];
            pmx[v]=tl;
            return;
        }
        int tm=(tl+tr)/2;
        build(2*v,tl,tm,H);
        build(2*v+1,tm+1,tr,H);
        mx[v]=max(mx[2*v],mx[2*v+1]);
        if(mx[2*v]>mx[2*v+1])pmx[v]=pmx[2*v];
        else pmx[v]=pmx[2*v+1];
        mn[v]=min(mn[2*v],mn[2*v+1]);
    }

    int getMn(int v,int tl,int tr,int l,int r){
        if(l>r||tl>r||l>tr)return inf;
        if(l<=tl&&tr<=r)return mn[v];
        int tm=(tl+tr)/2;
        return min(getMn(2*v,tl,tm,l,r),getMn(2*v+1,tm+1,tr,l,r));
    }

    pii getMx(int v,int tl,int tr,int l,int r){
        if(l>r||tl>r||l>tr)return {-inf,-inf};
        if(l<=tl&&tr<=r)return {mx[v],pmx[v]};
        int tm=(tl+tr)/2;
        return max(getMx(2*v,tl,tm,l,r),getMx(2*v+1,tm+1,tr,l,r));
    }
}T;

int n;

void init(int N, vector<int> H) {
    T.build(1,0,N-1,H);
    n=N;
}

int get(int l,int r,int d,int g){
    if(l>r)return 0;
    int ans=0;
    if(T.getMn(1,0,n-1,l,r)<=g){
        ans=1;
    }
    auto [mx,pos]=T.getMx(1,0,n-1,l,r);
    ans=max(ans,get(l,pos-1,d,mx-d)+get(pos+1,r,d,mx-d));
    return ans;
}

int max_towers(int L, int R, int D) {
    return get(L,R,D,inf);
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4101 ms 9156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 412 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 412 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 696 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 412 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 412 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 696 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 15 ms 2392 KB Output is correct
37 Correct 17 ms 4184 KB Output is correct
38 Correct 16 ms 4164 KB Output is correct
39 Correct 23 ms 4184 KB Output is correct
40 Correct 14 ms 4164 KB Output is correct
41 Correct 28 ms 4164 KB Output is correct
42 Correct 11 ms 4304 KB Output is correct
43 Correct 27 ms 10960 KB Output is correct
44 Correct 17 ms 5820 KB Output is correct
45 Correct 17 ms 4184 KB Output is correct
46 Correct 11 ms 4304 KB Output is correct
47 Correct 18 ms 4148 KB Output is correct
48 Correct 14 ms 4184 KB Output is correct
49 Correct 13 ms 4160 KB Output is correct
50 Correct 17 ms 6864 KB Output is correct
51 Correct 22 ms 9424 KB Output is correct
52 Correct 31 ms 4168 KB Output is correct
53 Correct 30 ms 4184 KB Output is correct
54 Correct 30 ms 4184 KB Output is correct
55 Correct 32 ms 17824 KB Output is correct
56 Correct 38 ms 16584 KB Output is correct
57 Correct 29 ms 4184 KB Output is correct
58 Correct 30 ms 4184 KB Output is correct
59 Correct 37 ms 4436 KB Output is correct
60 Correct 30 ms 4184 KB Output is correct
61 Correct 31 ms 4276 KB Output is correct
62 Correct 40 ms 4188 KB Output is correct
63 Correct 37 ms 4164 KB Output is correct
64 Correct 34 ms 17836 KB Output is correct
65 Correct 32 ms 17864 KB Output is correct
66 Correct 39 ms 12492 KB Output is correct
67 Correct 33 ms 17096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4025 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4038 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 412 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 412 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 696 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 15 ms 2392 KB Output is correct
37 Correct 17 ms 4184 KB Output is correct
38 Correct 16 ms 4164 KB Output is correct
39 Correct 23 ms 4184 KB Output is correct
40 Correct 14 ms 4164 KB Output is correct
41 Correct 28 ms 4164 KB Output is correct
42 Correct 11 ms 4304 KB Output is correct
43 Correct 27 ms 10960 KB Output is correct
44 Correct 17 ms 5820 KB Output is correct
45 Correct 17 ms 4184 KB Output is correct
46 Correct 11 ms 4304 KB Output is correct
47 Correct 18 ms 4148 KB Output is correct
48 Correct 14 ms 4184 KB Output is correct
49 Correct 13 ms 4160 KB Output is correct
50 Correct 17 ms 6864 KB Output is correct
51 Correct 22 ms 9424 KB Output is correct
52 Correct 31 ms 4168 KB Output is correct
53 Correct 30 ms 4184 KB Output is correct
54 Correct 30 ms 4184 KB Output is correct
55 Correct 32 ms 17824 KB Output is correct
56 Correct 38 ms 16584 KB Output is correct
57 Correct 29 ms 4184 KB Output is correct
58 Correct 30 ms 4184 KB Output is correct
59 Correct 37 ms 4436 KB Output is correct
60 Correct 30 ms 4184 KB Output is correct
61 Correct 31 ms 4276 KB Output is correct
62 Correct 40 ms 4188 KB Output is correct
63 Correct 37 ms 4164 KB Output is correct
64 Correct 34 ms 17836 KB Output is correct
65 Correct 32 ms 17864 KB Output is correct
66 Correct 39 ms 12492 KB Output is correct
67 Correct 33 ms 17096 KB Output is correct
68 Execution timed out 4025 ms 4184 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4101 ms 9156 KB Time limit exceeded
2 Halted 0 ms 0 KB -