Submission #1035087

# Submission time Handle Problem Language Result Execution time Memory
1035087 2024-07-26T04:07:33 Z irmuun Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 6216 KB
#include<bits/stdc++.h>
#include "towers.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

struct segtree{
    vector<int>u,d;
    void init(int n,vector<int>h){
        u=h;
        d.resize(4*n);
        build(1,0,n-1);
    }
    void build(int v,int l,int r){
        if(l==r){
            d[v]=u[l];
            return;
        }
        int mid=(l+r)>>1;
        build(v*2,l,mid);
        build(v*2+1,mid+1,r);
        d[v]=max(d[v*2],d[v*2+1]);
    }
    int query(int v,int l,int r,int L,int R){
        if(R<L||r<L||R<l) return 0;
        if(L<=l&&r<=R){
            return d[v];
        }
        int mid=(l+r)>>1;
        return max(query(v*2,l,mid,L,R),query(v*2+1,mid+1,r,L,R));
    }
};

segtree sg;

int n;
vector<int>h;
vector<pair<int,int>>v;
vector<bool>used;

void init(int N,vector<int>H){
    n=N; h=H;
    used.resize(n);
    for(int i=0;i<n;i++){
        v.pb({H[i],i});
    }
    sort(all(v));
    sg.init(n,h);
}

int max_towers(int L,int R,int D){
    int ans=0;
    set<int>st;
    st.insert(-1);
    st.insert(n);
    for(auto [x,i]:v){
        if(i<L||i>R) continue;
        bool add=true;
        auto it=st.lower_bound(i); it--;
        if(*it!=-1){
            if(sg.query(1,0,n-1,(*it)+1,i-1)<x+D){
                add=false;
            }
        }
        it++;
        if(*it!=n){
            if(sg.query(1,0,n-1,i+1,(*it)-1)<x+D){
                add=false;
            }
        }
        if(add){
            ans++;
            st.insert(i);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4009 ms 3024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 480 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 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 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 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 440 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 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 480 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 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 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 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 440 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 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 17 ms 3024 KB Output is correct
37 Correct 29 ms 4548 KB Output is correct
38 Correct 22 ms 4556 KB Output is correct
39 Correct 27 ms 4556 KB Output is correct
40 Correct 20 ms 4556 KB Output is correct
41 Correct 47 ms 4648 KB Output is correct
42 Correct 18 ms 4556 KB Output is correct
43 Correct 20 ms 4556 KB Output is correct
44 Correct 13 ms 4556 KB Output is correct
45 Correct 13 ms 4520 KB Output is correct
46 Correct 12 ms 4556 KB Output is correct
47 Correct 28 ms 4548 KB Output is correct
48 Correct 23 ms 4556 KB Output is correct
49 Correct 19 ms 4556 KB Output is correct
50 Correct 14 ms 4636 KB Output is correct
51 Correct 16 ms 4556 KB Output is correct
52 Correct 57 ms 5420 KB Output is correct
53 Correct 53 ms 6204 KB Output is correct
54 Correct 59 ms 6216 KB Output is correct
55 Correct 24 ms 4556 KB Output is correct
56 Correct 30 ms 4628 KB Output is correct
57 Correct 52 ms 4524 KB Output is correct
58 Correct 57 ms 4720 KB Output is correct
59 Correct 55 ms 5128 KB Output is correct
60 Correct 54 ms 6068 KB Output is correct
61 Correct 53 ms 5936 KB Output is correct
62 Correct 54 ms 5180 KB Output is correct
63 Correct 53 ms 5948 KB Output is correct
64 Correct 29 ms 4556 KB Output is correct
65 Correct 24 ms 4556 KB Output is correct
66 Correct 40 ms 4808 KB Output is correct
67 Correct 31 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4081 ms 5440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4069 ms 1636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 ms 480 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 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 2 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 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 440 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 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 17 ms 3024 KB Output is correct
37 Correct 29 ms 4548 KB Output is correct
38 Correct 22 ms 4556 KB Output is correct
39 Correct 27 ms 4556 KB Output is correct
40 Correct 20 ms 4556 KB Output is correct
41 Correct 47 ms 4648 KB Output is correct
42 Correct 18 ms 4556 KB Output is correct
43 Correct 20 ms 4556 KB Output is correct
44 Correct 13 ms 4556 KB Output is correct
45 Correct 13 ms 4520 KB Output is correct
46 Correct 12 ms 4556 KB Output is correct
47 Correct 28 ms 4548 KB Output is correct
48 Correct 23 ms 4556 KB Output is correct
49 Correct 19 ms 4556 KB Output is correct
50 Correct 14 ms 4636 KB Output is correct
51 Correct 16 ms 4556 KB Output is correct
52 Correct 57 ms 5420 KB Output is correct
53 Correct 53 ms 6204 KB Output is correct
54 Correct 59 ms 6216 KB Output is correct
55 Correct 24 ms 4556 KB Output is correct
56 Correct 30 ms 4628 KB Output is correct
57 Correct 52 ms 4524 KB Output is correct
58 Correct 57 ms 4720 KB Output is correct
59 Correct 55 ms 5128 KB Output is correct
60 Correct 54 ms 6068 KB Output is correct
61 Correct 53 ms 5936 KB Output is correct
62 Correct 54 ms 5180 KB Output is correct
63 Correct 53 ms 5948 KB Output is correct
64 Correct 29 ms 4556 KB Output is correct
65 Correct 24 ms 4556 KB Output is correct
66 Correct 40 ms 4808 KB Output is correct
67 Correct 31 ms 4556 KB Output is correct
68 Execution timed out 4081 ms 5440 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4009 ms 3024 KB Time limit exceeded
2 Halted 0 ms 0 KB -