답안 #501788

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501788 2022-01-04T14:52:06 Z dxz05 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
64 / 100
577 ms 100480 KB
//#pragma GCC optimize("Ofast,O2,O3,unroll-loops")
//#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

int t[2200000];

void update(int v, int tl, int tr, int pos, int val){
    if (tl == tr){
        t[v] = max(t[v], val);
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos <= tm) update(v + v, tl, tm, pos, val); else
        update(v + v + 1, tm + 1, tr, pos, val);

    t[v] = max(t[v + v], t[v + v + 1]);
}

int get(int v, int tl, int tr, int l, int r){
    if (l <= tl && tr <= r) return t[v];
    if (tl > r || tr < l) return 0;
    int tm = (tl + tr) >> 1;
    return max(get(v + v, tl, tm, l, r), get(v + v + 1, tm + 1, tr, l, r));
}

int a[1000005];
vector<pair<int, pair<int, int>>> queries[1000005];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n, q;
    cin >> n >> q;

    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }

    for (int i = 1; i <= q; i++){
        int l, r, k;
        cin >> l >> r >> k;
        queries[r].emplace_back(l, make_pair(k, i));
    }

    bitset<200001> ans;

    a[0] = 2e9;
    stack<int> st;
    st.push(0);
    for (int i = 1; i <= n; i++){
        while (!st.empty() && a[st.top()] <= a[i]) st.pop();
        int j = st.top();
        if (j != 0) update(1, 1, n, j, a[j] + a[i]);

        for (auto qu : queries[i]){
            int l = qu.first, k = qu.second.first, ind = qu.second.second;
            ans[ind] = get(1, 1, n, l, i) <= k;
        }

        st.push(i);
    }

    for (int i = 1; i <= q; i++) cout << ans[i] << '\n';


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 13 ms 23836 KB Output is correct
3 Correct 12 ms 23832 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23832 KB Output is correct
6 Correct 13 ms 23864 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 13 ms 23756 KB Output is correct
10 Correct 14 ms 23832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 13 ms 23836 KB Output is correct
3 Correct 12 ms 23832 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23832 KB Output is correct
6 Correct 13 ms 23864 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 13 ms 23756 KB Output is correct
10 Correct 14 ms 23832 KB Output is correct
11 Correct 16 ms 23832 KB Output is correct
12 Correct 15 ms 24012 KB Output is correct
13 Correct 15 ms 23968 KB Output is correct
14 Correct 17 ms 24092 KB Output is correct
15 Correct 16 ms 24012 KB Output is correct
16 Correct 16 ms 24016 KB Output is correct
17 Correct 15 ms 23964 KB Output is correct
18 Correct 17 ms 24012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 577 ms 100480 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 27600 KB Output is correct
2 Correct 91 ms 27384 KB Output is correct
3 Correct 84 ms 26436 KB Output is correct
4 Correct 78 ms 26516 KB Output is correct
5 Correct 104 ms 26732 KB Output is correct
6 Correct 72 ms 26108 KB Output is correct
7 Correct 73 ms 26212 KB Output is correct
8 Correct 76 ms 26580 KB Output is correct
9 Correct 48 ms 25640 KB Output is correct
10 Correct 89 ms 26624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 13 ms 23836 KB Output is correct
3 Correct 12 ms 23832 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23832 KB Output is correct
6 Correct 13 ms 23864 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 13 ms 23756 KB Output is correct
10 Correct 14 ms 23832 KB Output is correct
11 Correct 16 ms 23832 KB Output is correct
12 Correct 15 ms 24012 KB Output is correct
13 Correct 15 ms 23968 KB Output is correct
14 Correct 17 ms 24092 KB Output is correct
15 Correct 16 ms 24012 KB Output is correct
16 Correct 16 ms 24016 KB Output is correct
17 Correct 15 ms 23964 KB Output is correct
18 Correct 17 ms 24012 KB Output is correct
19 Correct 217 ms 31444 KB Output is correct
20 Correct 213 ms 31340 KB Output is correct
21 Correct 176 ms 30844 KB Output is correct
22 Correct 197 ms 30876 KB Output is correct
23 Correct 180 ms 30904 KB Output is correct
24 Correct 156 ms 28868 KB Output is correct
25 Correct 174 ms 28836 KB Output is correct
26 Correct 169 ms 29000 KB Output is correct
27 Correct 185 ms 28984 KB Output is correct
28 Correct 175 ms 29064 KB Output is correct
29 Correct 186 ms 29380 KB Output is correct
30 Correct 229 ms 29508 KB Output is correct
31 Correct 175 ms 29340 KB Output is correct
32 Correct 215 ms 29360 KB Output is correct
33 Correct 172 ms 29252 KB Output is correct
34 Correct 158 ms 28556 KB Output is correct
35 Correct 162 ms 28456 KB Output is correct
36 Correct 138 ms 28476 KB Output is correct
37 Correct 141 ms 28488 KB Output is correct
38 Correct 163 ms 28444 KB Output is correct
39 Correct 158 ms 29704 KB Output is correct
40 Correct 126 ms 28396 KB Output is correct
41 Correct 193 ms 29268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 13 ms 23836 KB Output is correct
3 Correct 12 ms 23832 KB Output is correct
4 Correct 13 ms 23780 KB Output is correct
5 Correct 13 ms 23832 KB Output is correct
6 Correct 13 ms 23864 KB Output is correct
7 Correct 14 ms 23824 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 13 ms 23756 KB Output is correct
10 Correct 14 ms 23832 KB Output is correct
11 Correct 16 ms 23832 KB Output is correct
12 Correct 15 ms 24012 KB Output is correct
13 Correct 15 ms 23968 KB Output is correct
14 Correct 17 ms 24092 KB Output is correct
15 Correct 16 ms 24012 KB Output is correct
16 Correct 16 ms 24016 KB Output is correct
17 Correct 15 ms 23964 KB Output is correct
18 Correct 17 ms 24012 KB Output is correct
19 Runtime error 577 ms 100480 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -