Submission #826817

# Submission time Handle Problem Language Result Execution time Memory
826817 2023-08-16T04:57:21 Z physics07 Radio Towers (IOI22_towers) C++17
17 / 100
840 ms 7252 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inf=1e9+7;
int n, lt[100001], rt[100001];
map<int, int> del, sum;
stack<int> stk;
struct seg {
    int tree[100001*2], sz;
    void init(int n) {sz=n;}
    void update(int idx, int v) {
        for(tree[idx+=sz]+=v; idx>1; idx>>=1) tree[idx>>1]=max(tree[idx], tree[idx^1]);
    }
    int query(int l, int r) {
        int res=0;
        for(l+=sz, r+=sz; l<=r; l>>=1, r>>=1) {
            if(l&1) res=max(res, tree[l++]);
            if(~r&1) res=max(res, tree[r--]);
        }
        return res;
    }
} tree;
void init(int N, vector<int> a) {
    n=N;
    tree.init(n);
    for(int i=0; i<n; i++) tree.update(i, a[i]);
    for(int i=0; i<n; i++) {
        while(!stk.empty() && a[stk.top()]>a[i]) stk.pop();
        lt[i]=(stk.empty() ? -1 : stk.top());
        stk.push(i);
    }
    while(!stk.empty()) stk.pop();
    for(int i=n-1; i>=0; i--) {
        while(!stk.empty() && a[stk.top()]>a[i]) stk.pop();
        rt[i]=(stk.empty() ? n : stk.top());
        stk.push(i);
    }
    for(int i=0; i<n; i++) {
        int curr=inf;
        if(lt[i]>=0) curr=min(curr, tree.query(lt[i]+1, i));
        if(rt[i]<n) curr=min(curr, tree.query(i, rt[i]-1));
        if(curr==inf) {
            del[inf]++;
            continue;
        }
        if(curr>a[i]) del[curr-a[i]]++;
    }
    int prv=0;
    for(auto it=del.rbegin(); it!=del.rend(); it++) {
        prv+=it->second;
        sum[it->first]=prv;
    }
}

int max_towers(int l, int r, int d) {
    return sum.lower_bound(d)->second;
}
# Verdict Execution time Memory Grader output
1 Incorrect 296 ms 1872 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 571 ms 5712 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 224 ms 1616 KB Output is correct
2 Correct 795 ms 5732 KB Output is correct
3 Correct 766 ms 5672 KB Output is correct
4 Correct 751 ms 7240 KB Output is correct
5 Correct 677 ms 7232 KB Output is correct
6 Correct 715 ms 7232 KB Output is correct
7 Correct 678 ms 7204 KB Output is correct
8 Correct 840 ms 3016 KB Output is correct
9 Correct 756 ms 2936 KB Output is correct
10 Correct 544 ms 2892 KB Output is correct
11 Correct 583 ms 2892 KB Output is correct
12 Correct 26 ms 5696 KB Output is correct
13 Correct 38 ms 7228 KB Output is correct
14 Correct 32 ms 7240 KB Output is correct
15 Correct 11 ms 3024 KB Output is correct
16 Correct 15 ms 2768 KB Output is correct
17 Correct 26 ms 5576 KB Output is correct
18 Correct 27 ms 5648 KB Output is correct
19 Correct 33 ms 5692 KB Output is correct
20 Correct 32 ms 7252 KB Output is correct
21 Correct 32 ms 7240 KB Output is correct
22 Correct 32 ms 7208 KB Output is correct
23 Correct 38 ms 7240 KB Output is correct
24 Correct 11 ms 3016 KB Output is correct
25 Correct 13 ms 3016 KB Output is correct
26 Correct 15 ms 2864 KB Output is correct
27 Correct 11 ms 3016 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 0 ms 336 KB Output is correct
32 Correct 0 ms 336 KB Output is correct
33 Correct 0 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 1 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 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 0 ms 336 KB Output is correct
43 Correct 0 ms 336 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 296 ms 1872 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -