답안 #716286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716286 2023-03-29T13:29:30 Z Jarif_Rahman 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 4484 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

struct segtree{
    int k = 1;
    vector<int> v;
    segtree(int n){
        while(k < n) k*=2;
        v.assign(2*k, 0);
    }
    void update(int i, int x){
        i+=k;
        v[i] = x;
        i/=2;
        while(i){
            v[i] = max(v[2*i], v[2*i+1]);
            i/=2;
        }
    }
    int get(int l, int r, int nd, int a, int b){
        if(a > r || b < l) return 0;
        if(a >= l && b <= r) return v[nd];
        int md = (a+b)/2;
        return max(get(l, r, 2*nd, a, md), get(l, r, 2*nd+1, md+1, b));
    }
    int get(int l, int r){
        if(l > r) return 0;
        return get(l, r, 1, 0, k-1);
    }
};

int n;
vector<int> h;
segtree seg(0);
vector<int> DL, DR, DLR;
vector<int> SL, SR;

void init(int _n, vector<int> _h){
    swap(n, _n);
    swap(h, _h);
    seg = segtree(n);
    DR.assign(n, 1e9);
    DL.assign(n, 1e9);
    DLR.assign(n, 1e9);
    SL.assign(n, 0);
    SR.resize(n, n-1);

    for(int i = 0; i < n; i++) seg.update(i, h[i]);

    stack<int> st;
    for(int i = n-1; i >= 0; i--){
        while(!st.empty() && h[i] < h[st.top()]){
            SL[st.top()] = i;
            DL[st.top()] = max(0, seg.get(i, st.top())-h[st.top()]);
            st.pop();
        }
        st.push(i);
    }
    while(!st.empty()) st.pop();
    for(int i = 0; i < n; i++){
        while(!st.empty() && h[i] < h[st.top()]){
            SR[st.top()] = i;
            DR[st.top()] = max(0, seg.get(st.top(), i)-h[st.top()]);
            st.pop();
        }
        st.push(i);
    }
    while(!st.empty()) st.pop();

    for(int i = 0;  i < n; i++) DLR[i] = min(DL[i], DR[i]);
}

int max_towers(int L, int R, int D){
    int ans = 0;
    for(int i = L; i <= R; i++){
        if(SL[i] >= L && SR[i] <= R) ans+=(D <= DLR[i]);
        else if(SL[i] >= L) ans+=(D <= DL[i]);
        else if(SR[i] <= R) ans+=(D <= DR[i]);
        else ans++;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1541 ms 2664 KB Output is correct
2 Execution timed out 4011 ms 4388 KB Time limit exceeded
3 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 2 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 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 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 2 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 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 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 456 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 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 2 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 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 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 2 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 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 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 456 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 29 ms 2596 KB Output is correct
37 Correct 42 ms 3996 KB Output is correct
38 Correct 54 ms 4076 KB Output is correct
39 Correct 46 ms 4004 KB Output is correct
40 Correct 48 ms 4060 KB Output is correct
41 Correct 42 ms 4004 KB Output is correct
42 Correct 42 ms 4064 KB Output is correct
43 Correct 26 ms 4448 KB Output is correct
44 Correct 27 ms 4480 KB Output is correct
45 Correct 35 ms 4328 KB Output is correct
46 Correct 36 ms 4252 KB Output is correct
47 Correct 48 ms 4064 KB Output is correct
48 Correct 42 ms 4060 KB Output is correct
49 Correct 40 ms 4040 KB Output is correct
50 Correct 30 ms 4432 KB Output is correct
51 Correct 28 ms 4444 KB Output is correct
52 Correct 47 ms 4004 KB Output is correct
53 Correct 45 ms 4060 KB Output is correct
54 Correct 39 ms 4060 KB Output is correct
55 Correct 26 ms 4384 KB Output is correct
56 Correct 36 ms 4260 KB Output is correct
57 Correct 48 ms 3984 KB Output is correct
58 Correct 45 ms 4000 KB Output is correct
59 Correct 42 ms 4056 KB Output is correct
60 Correct 40 ms 4064 KB Output is correct
61 Correct 39 ms 3992 KB Output is correct
62 Correct 44 ms 4008 KB Output is correct
63 Correct 43 ms 4056 KB Output is correct
64 Correct 27 ms 4464 KB Output is correct
65 Correct 37 ms 4484 KB Output is correct
66 Correct 43 ms 4252 KB Output is correct
67 Correct 32 ms 4380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 4000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 984 ms 1212 KB Output is correct
2 Execution timed out 4011 ms 4008 KB Time limit exceeded
3 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 2 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 2 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 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 2 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 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 208 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 456 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 29 ms 2596 KB Output is correct
37 Correct 42 ms 3996 KB Output is correct
38 Correct 54 ms 4076 KB Output is correct
39 Correct 46 ms 4004 KB Output is correct
40 Correct 48 ms 4060 KB Output is correct
41 Correct 42 ms 4004 KB Output is correct
42 Correct 42 ms 4064 KB Output is correct
43 Correct 26 ms 4448 KB Output is correct
44 Correct 27 ms 4480 KB Output is correct
45 Correct 35 ms 4328 KB Output is correct
46 Correct 36 ms 4252 KB Output is correct
47 Correct 48 ms 4064 KB Output is correct
48 Correct 42 ms 4060 KB Output is correct
49 Correct 40 ms 4040 KB Output is correct
50 Correct 30 ms 4432 KB Output is correct
51 Correct 28 ms 4444 KB Output is correct
52 Correct 47 ms 4004 KB Output is correct
53 Correct 45 ms 4060 KB Output is correct
54 Correct 39 ms 4060 KB Output is correct
55 Correct 26 ms 4384 KB Output is correct
56 Correct 36 ms 4260 KB Output is correct
57 Correct 48 ms 3984 KB Output is correct
58 Correct 45 ms 4000 KB Output is correct
59 Correct 42 ms 4056 KB Output is correct
60 Correct 40 ms 4064 KB Output is correct
61 Correct 39 ms 3992 KB Output is correct
62 Correct 44 ms 4008 KB Output is correct
63 Correct 43 ms 4056 KB Output is correct
64 Correct 27 ms 4464 KB Output is correct
65 Correct 37 ms 4484 KB Output is correct
66 Correct 43 ms 4252 KB Output is correct
67 Correct 32 ms 4380 KB Output is correct
68 Execution timed out 4014 ms 4000 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1541 ms 2664 KB Output is correct
2 Execution timed out 4011 ms 4388 KB Time limit exceeded
3 Halted 0 ms 0 KB -