Submission #716256

# Submission time Handle Problem Language Result Execution time Memory
716256 2023-03-29T11:48:11 Z Jarif_Rahman Radio Towers (IOI22_towers) C++17
17 / 100
1075 ms 5044 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> o;
vector<int> diffs;

void init(int _n, vector<int> _h){
    swap(n, _n);
    swap(h, _h);
    seg = segtree(n);
    for(int i = 0; i < n; i++) seg.update(i, h[i]);
    for(int i = 0; i < n; i++) o.pb(i);
    sort(o.begin(), o.end(), [&](int a, int b){
        return h[a] < h[b];
    });

    set<int> s;
    for(int i: o){
        auto it = s.upper_bound(i);
        int x = 2e9;
        bool ok = 1;
        if(it != s.end()){
            int y = seg.get(i+1, *it-1);
            if(y < h[i]) ok = 0;
            x = min(x, y-h[i]);
        }
        if(it != s.begin()){
            int y = seg.get(*prev(it)+1, i-1);
            if(y < h[i]) ok = 0;
            x = min(x, y-h[i]);
        }
        if(ok) s.insert(i), diffs.pb(x);
    }

    sort(diffs.begin(), diffs.end());
}

int max_towers(int L, int R, int D){
    return int(diffs.size())-(lower_bound(diffs.begin(), diffs.end(), D)-diffs.begin());
}
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 1616 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 587 ms 4380 KB 1st lines differ - on the 1st token, expected: '11903', found: '33010'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 320 ms 1232 KB Output is correct
2 Correct 946 ms 4296 KB Output is correct
3 Correct 885 ms 4304 KB Output is correct
4 Correct 1075 ms 5036 KB Output is correct
5 Correct 737 ms 5040 KB Output is correct
6 Correct 656 ms 5044 KB Output is correct
7 Correct 824 ms 5044 KB Output is correct
8 Correct 578 ms 2764 KB Output is correct
9 Correct 651 ms 2712 KB Output is correct
10 Correct 757 ms 2748 KB Output is correct
11 Correct 857 ms 2764 KB Output is correct
12 Correct 80 ms 4260 KB Output is correct
13 Correct 73 ms 5024 KB Output is correct
14 Correct 70 ms 4916 KB Output is correct
15 Correct 32 ms 2764 KB Output is correct
16 Correct 48 ms 2720 KB Output is correct
17 Correct 77 ms 3988 KB Output is correct
18 Correct 84 ms 4304 KB Output is correct
19 Correct 71 ms 4268 KB Output is correct
20 Correct 70 ms 4960 KB Output is correct
21 Correct 70 ms 5044 KB Output is correct
22 Correct 78 ms 5044 KB Output is correct
23 Correct 76 ms 4920 KB Output is correct
24 Correct 35 ms 2732 KB Output is correct
25 Correct 32 ms 2712 KB Output is correct
26 Correct 42 ms 2716 KB Output is correct
27 Correct 43 ms 2652 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 2 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 2 ms 336 KB Output is correct
39 Correct 2 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 1 ms 336 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 1616 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -