Submission #651279

# Submission time Handle Problem Language Result Execution time Memory
651279 2022-10-18T05:59:40 Z becaido Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
890 ms 61512 KB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define Waimai ios::sync_with_stdio(false),cin.tie(0)
#define FOR(x,a,b) for(int x=a,I=b;x<=I;x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 1e6 + 5;

int n, q;
int a[SIZE], bit[SIZE];
bool ans[SIZE];
vector<pair<int, int>> st;
vector<tuple<int, int, int>> ask[SIZE];

void upd (int pos, int x) {
    for (; pos; pos -= pos & -pos) bit[pos] = max (bit[pos], x);
}

int que (int pos) {
    int re = 0;
    for (; pos <= n; pos += pos & -pos) re = max (re, bit[pos]);
    return re;
}

void solve() {
    cin >> n >> q;
    FOR (i, 1, n) cin >> a[i];
    FOR (i, 1, q) {
        int l, r, k;
        cin >> l >> r >> k;
        ask[r].pb (l, k, i);
    }
    FOR (i, 1, n) {
        while (st.size() && a[i] >= st.back().S) st.pop_back();
        if (st.size()) upd (st.back().F, st.back().S + a[i]);
        st.pb (i, a[i]);
        for (auto [l, k, id] : ask[i]) ans[id] = que (l) <= k;
    }
    FOR (i, 1, q) cout << ans[i] << '\n';
}

int main() {
    Waimai;
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23764 KB Output is correct
2 Correct 18 ms 23776 KB Output is correct
3 Correct 15 ms 23808 KB Output is correct
4 Correct 14 ms 23796 KB Output is correct
5 Correct 15 ms 23816 KB Output is correct
6 Correct 16 ms 23816 KB Output is correct
7 Correct 15 ms 23908 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 18 ms 23824 KB Output is correct
10 Correct 16 ms 23804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23764 KB Output is correct
2 Correct 18 ms 23776 KB Output is correct
3 Correct 15 ms 23808 KB Output is correct
4 Correct 14 ms 23796 KB Output is correct
5 Correct 15 ms 23816 KB Output is correct
6 Correct 16 ms 23816 KB Output is correct
7 Correct 15 ms 23908 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 18 ms 23824 KB Output is correct
10 Correct 16 ms 23804 KB Output is correct
11 Correct 16 ms 23884 KB Output is correct
12 Correct 15 ms 24008 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 17 ms 24020 KB Output is correct
15 Correct 19 ms 24084 KB Output is correct
16 Correct 15 ms 24024 KB Output is correct
17 Correct 17 ms 24056 KB Output is correct
18 Correct 18 ms 24020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 853 ms 61076 KB Output is correct
2 Correct 863 ms 56560 KB Output is correct
3 Correct 838 ms 56456 KB Output is correct
4 Correct 829 ms 56748 KB Output is correct
5 Correct 790 ms 58128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 28920 KB Output is correct
2 Correct 64 ms 28620 KB Output is correct
3 Correct 70 ms 28512 KB Output is correct
4 Correct 68 ms 28492 KB Output is correct
5 Correct 94 ms 28512 KB Output is correct
6 Correct 55 ms 27992 KB Output is correct
7 Correct 55 ms 28000 KB Output is correct
8 Correct 64 ms 28076 KB Output is correct
9 Correct 49 ms 26856 KB Output is correct
10 Correct 62 ms 28156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23764 KB Output is correct
2 Correct 18 ms 23776 KB Output is correct
3 Correct 15 ms 23808 KB Output is correct
4 Correct 14 ms 23796 KB Output is correct
5 Correct 15 ms 23816 KB Output is correct
6 Correct 16 ms 23816 KB Output is correct
7 Correct 15 ms 23908 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 18 ms 23824 KB Output is correct
10 Correct 16 ms 23804 KB Output is correct
11 Correct 16 ms 23884 KB Output is correct
12 Correct 15 ms 24008 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 17 ms 24020 KB Output is correct
15 Correct 19 ms 24084 KB Output is correct
16 Correct 15 ms 24024 KB Output is correct
17 Correct 17 ms 24056 KB Output is correct
18 Correct 18 ms 24020 KB Output is correct
19 Correct 165 ms 34292 KB Output is correct
20 Correct 158 ms 34352 KB Output is correct
21 Correct 137 ms 36272 KB Output is correct
22 Correct 145 ms 36204 KB Output is correct
23 Correct 155 ms 36004 KB Output is correct
24 Correct 121 ms 35196 KB Output is correct
25 Correct 117 ms 35088 KB Output is correct
26 Correct 157 ms 35564 KB Output is correct
27 Correct 141 ms 35508 KB Output is correct
28 Correct 166 ms 35612 KB Output is correct
29 Correct 149 ms 35996 KB Output is correct
30 Correct 151 ms 36068 KB Output is correct
31 Correct 170 ms 35964 KB Output is correct
32 Correct 152 ms 36028 KB Output is correct
33 Correct 141 ms 35916 KB Output is correct
34 Correct 119 ms 34864 KB Output is correct
35 Correct 125 ms 34636 KB Output is correct
36 Correct 110 ms 34468 KB Output is correct
37 Correct 128 ms 34508 KB Output is correct
38 Correct 115 ms 34784 KB Output is correct
39 Correct 169 ms 34484 KB Output is correct
40 Correct 123 ms 32948 KB Output is correct
41 Correct 144 ms 33824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23764 KB Output is correct
2 Correct 18 ms 23776 KB Output is correct
3 Correct 15 ms 23808 KB Output is correct
4 Correct 14 ms 23796 KB Output is correct
5 Correct 15 ms 23816 KB Output is correct
6 Correct 16 ms 23816 KB Output is correct
7 Correct 15 ms 23908 KB Output is correct
8 Correct 15 ms 23764 KB Output is correct
9 Correct 18 ms 23824 KB Output is correct
10 Correct 16 ms 23804 KB Output is correct
11 Correct 16 ms 23884 KB Output is correct
12 Correct 15 ms 24008 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 17 ms 24020 KB Output is correct
15 Correct 19 ms 24084 KB Output is correct
16 Correct 15 ms 24024 KB Output is correct
17 Correct 17 ms 24056 KB Output is correct
18 Correct 18 ms 24020 KB Output is correct
19 Correct 853 ms 61076 KB Output is correct
20 Correct 863 ms 56560 KB Output is correct
21 Correct 838 ms 56456 KB Output is correct
22 Correct 829 ms 56748 KB Output is correct
23 Correct 790 ms 58128 KB Output is correct
24 Correct 78 ms 28920 KB Output is correct
25 Correct 64 ms 28620 KB Output is correct
26 Correct 70 ms 28512 KB Output is correct
27 Correct 68 ms 28492 KB Output is correct
28 Correct 94 ms 28512 KB Output is correct
29 Correct 55 ms 27992 KB Output is correct
30 Correct 55 ms 28000 KB Output is correct
31 Correct 64 ms 28076 KB Output is correct
32 Correct 49 ms 26856 KB Output is correct
33 Correct 62 ms 28156 KB Output is correct
34 Correct 165 ms 34292 KB Output is correct
35 Correct 158 ms 34352 KB Output is correct
36 Correct 137 ms 36272 KB Output is correct
37 Correct 145 ms 36204 KB Output is correct
38 Correct 155 ms 36004 KB Output is correct
39 Correct 121 ms 35196 KB Output is correct
40 Correct 117 ms 35088 KB Output is correct
41 Correct 157 ms 35564 KB Output is correct
42 Correct 141 ms 35508 KB Output is correct
43 Correct 166 ms 35612 KB Output is correct
44 Correct 149 ms 35996 KB Output is correct
45 Correct 151 ms 36068 KB Output is correct
46 Correct 170 ms 35964 KB Output is correct
47 Correct 152 ms 36028 KB Output is correct
48 Correct 141 ms 35916 KB Output is correct
49 Correct 119 ms 34864 KB Output is correct
50 Correct 125 ms 34636 KB Output is correct
51 Correct 110 ms 34468 KB Output is correct
52 Correct 128 ms 34508 KB Output is correct
53 Correct 115 ms 34784 KB Output is correct
54 Correct 169 ms 34484 KB Output is correct
55 Correct 123 ms 32948 KB Output is correct
56 Correct 144 ms 33824 KB Output is correct
57 Correct 848 ms 61512 KB Output is correct
58 Correct 873 ms 61468 KB Output is correct
59 Correct 847 ms 60000 KB Output is correct
60 Correct 815 ms 59944 KB Output is correct
61 Correct 787 ms 59852 KB Output is correct
62 Correct 841 ms 59904 KB Output is correct
63 Correct 550 ms 54184 KB Output is correct
64 Correct 631 ms 54156 KB Output is correct
65 Correct 787 ms 55796 KB Output is correct
66 Correct 820 ms 55808 KB Output is correct
67 Correct 843 ms 55760 KB Output is correct
68 Correct 831 ms 57412 KB Output is correct
69 Correct 876 ms 57424 KB Output is correct
70 Correct 828 ms 56760 KB Output is correct
71 Correct 846 ms 55132 KB Output is correct
72 Correct 890 ms 55080 KB Output is correct
73 Correct 491 ms 49452 KB Output is correct
74 Correct 513 ms 49648 KB Output is correct
75 Correct 510 ms 49696 KB Output is correct
76 Correct 539 ms 48344 KB Output is correct
77 Correct 543 ms 47124 KB Output is correct
78 Correct 730 ms 51912 KB Output is correct
79 Correct 558 ms 46380 KB Output is correct
80 Correct 683 ms 50400 KB Output is correct