답안 #539324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539324 2022-03-18T17:35:23 Z Evang Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
1213 ms 63544 KB
#include <bits/stdc++.h>
using namespace std;


const int N = 1e6+5;
const int Q = N;
int n, q, a[N], bit[N];
vector<int> qs[N];
bitset<N> ans;
struct evan {
    int l, r, k;
} query[Q];

void upd(int i, int x){
    while(i>0){
        bit[i] = max(bit[i], x);
        i -= i&-i;
    }
}

int qry(int i){
    int r = 0;
    while(i<=n){
        r = max(r, bit[i]);
        i += i&-i;
    }
    return r;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> q;
    a[0] = int(1e9)+1;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 0; i < q; ++i){
        cin >> query[i].l >> query[i].r >> query[i].k;
        qs[query[i].r].push_back(i);
    }

    vector<int> st{0};
    for(int i = 1; i <= n; ++i){
        while(a[st.back()]<=a[i])
            st.pop_back();
        upd(st.back(), a[i]+a[st.back()]);
        st.push_back(i);
        for(int j: qs[i])
            ans[j] = qry(query[j].l) <= query[j].k;
    }
    for(int i = 0; i < q; ++i)
        cout << ans[i] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23736 KB Output is correct
2 Correct 14 ms 23820 KB Output is correct
3 Correct 14 ms 23804 KB Output is correct
4 Correct 15 ms 23856 KB Output is correct
5 Correct 17 ms 23784 KB Output is correct
6 Correct 13 ms 23860 KB Output is correct
7 Correct 14 ms 23820 KB Output is correct
8 Correct 18 ms 23792 KB Output is correct
9 Correct 18 ms 23764 KB Output is correct
10 Correct 16 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23736 KB Output is correct
2 Correct 14 ms 23820 KB Output is correct
3 Correct 14 ms 23804 KB Output is correct
4 Correct 15 ms 23856 KB Output is correct
5 Correct 17 ms 23784 KB Output is correct
6 Correct 13 ms 23860 KB Output is correct
7 Correct 14 ms 23820 KB Output is correct
8 Correct 18 ms 23792 KB Output is correct
9 Correct 18 ms 23764 KB Output is correct
10 Correct 16 ms 23764 KB Output is correct
11 Correct 15 ms 23896 KB Output is correct
12 Correct 19 ms 24064 KB Output is correct
13 Correct 16 ms 23960 KB Output is correct
14 Correct 17 ms 24128 KB Output is correct
15 Correct 17 ms 24084 KB Output is correct
16 Correct 18 ms 24124 KB Output is correct
17 Correct 19 ms 24032 KB Output is correct
18 Correct 23 ms 24096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1148 ms 63524 KB Output is correct
2 Correct 1071 ms 63452 KB Output is correct
3 Correct 1100 ms 63360 KB Output is correct
4 Correct 1046 ms 63544 KB Output is correct
5 Correct 1006 ms 59532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 27728 KB Output is correct
2 Correct 65 ms 27052 KB Output is correct
3 Correct 71 ms 27168 KB Output is correct
4 Correct 74 ms 27396 KB Output is correct
5 Correct 66 ms 27476 KB Output is correct
6 Correct 58 ms 26388 KB Output is correct
7 Correct 84 ms 26340 KB Output is correct
8 Correct 65 ms 27384 KB Output is correct
9 Correct 50 ms 26932 KB Output is correct
10 Correct 94 ms 28296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23736 KB Output is correct
2 Correct 14 ms 23820 KB Output is correct
3 Correct 14 ms 23804 KB Output is correct
4 Correct 15 ms 23856 KB Output is correct
5 Correct 17 ms 23784 KB Output is correct
6 Correct 13 ms 23860 KB Output is correct
7 Correct 14 ms 23820 KB Output is correct
8 Correct 18 ms 23792 KB Output is correct
9 Correct 18 ms 23764 KB Output is correct
10 Correct 16 ms 23764 KB Output is correct
11 Correct 15 ms 23896 KB Output is correct
12 Correct 19 ms 24064 KB Output is correct
13 Correct 16 ms 23960 KB Output is correct
14 Correct 17 ms 24128 KB Output is correct
15 Correct 17 ms 24084 KB Output is correct
16 Correct 18 ms 24124 KB Output is correct
17 Correct 19 ms 24032 KB Output is correct
18 Correct 23 ms 24096 KB Output is correct
19 Correct 234 ms 32652 KB Output is correct
20 Correct 173 ms 32636 KB Output is correct
21 Correct 153 ms 30884 KB Output is correct
22 Correct 149 ms 30912 KB Output is correct
23 Correct 156 ms 30944 KB Output is correct
24 Correct 133 ms 29944 KB Output is correct
25 Correct 145 ms 30024 KB Output is correct
26 Correct 195 ms 30720 KB Output is correct
27 Correct 151 ms 30840 KB Output is correct
28 Correct 159 ms 31008 KB Output is correct
29 Correct 188 ms 31812 KB Output is correct
30 Correct 153 ms 31868 KB Output is correct
31 Correct 175 ms 31808 KB Output is correct
32 Correct 223 ms 31760 KB Output is correct
33 Correct 160 ms 31756 KB Output is correct
34 Correct 128 ms 29804 KB Output is correct
35 Correct 133 ms 29776 KB Output is correct
36 Correct 134 ms 29808 KB Output is correct
37 Correct 115 ms 29704 KB Output is correct
38 Correct 122 ms 29776 KB Output is correct
39 Correct 172 ms 31792 KB Output is correct
40 Correct 177 ms 30964 KB Output is correct
41 Correct 154 ms 31632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 23736 KB Output is correct
2 Correct 14 ms 23820 KB Output is correct
3 Correct 14 ms 23804 KB Output is correct
4 Correct 15 ms 23856 KB Output is correct
5 Correct 17 ms 23784 KB Output is correct
6 Correct 13 ms 23860 KB Output is correct
7 Correct 14 ms 23820 KB Output is correct
8 Correct 18 ms 23792 KB Output is correct
9 Correct 18 ms 23764 KB Output is correct
10 Correct 16 ms 23764 KB Output is correct
11 Correct 15 ms 23896 KB Output is correct
12 Correct 19 ms 24064 KB Output is correct
13 Correct 16 ms 23960 KB Output is correct
14 Correct 17 ms 24128 KB Output is correct
15 Correct 17 ms 24084 KB Output is correct
16 Correct 18 ms 24124 KB Output is correct
17 Correct 19 ms 24032 KB Output is correct
18 Correct 23 ms 24096 KB Output is correct
19 Correct 1148 ms 63524 KB Output is correct
20 Correct 1071 ms 63452 KB Output is correct
21 Correct 1100 ms 63360 KB Output is correct
22 Correct 1046 ms 63544 KB Output is correct
23 Correct 1006 ms 59532 KB Output is correct
24 Correct 89 ms 27728 KB Output is correct
25 Correct 65 ms 27052 KB Output is correct
26 Correct 71 ms 27168 KB Output is correct
27 Correct 74 ms 27396 KB Output is correct
28 Correct 66 ms 27476 KB Output is correct
29 Correct 58 ms 26388 KB Output is correct
30 Correct 84 ms 26340 KB Output is correct
31 Correct 65 ms 27384 KB Output is correct
32 Correct 50 ms 26932 KB Output is correct
33 Correct 94 ms 28296 KB Output is correct
34 Correct 234 ms 32652 KB Output is correct
35 Correct 173 ms 32636 KB Output is correct
36 Correct 153 ms 30884 KB Output is correct
37 Correct 149 ms 30912 KB Output is correct
38 Correct 156 ms 30944 KB Output is correct
39 Correct 133 ms 29944 KB Output is correct
40 Correct 145 ms 30024 KB Output is correct
41 Correct 195 ms 30720 KB Output is correct
42 Correct 151 ms 30840 KB Output is correct
43 Correct 159 ms 31008 KB Output is correct
44 Correct 188 ms 31812 KB Output is correct
45 Correct 153 ms 31868 KB Output is correct
46 Correct 175 ms 31808 KB Output is correct
47 Correct 223 ms 31760 KB Output is correct
48 Correct 160 ms 31756 KB Output is correct
49 Correct 128 ms 29804 KB Output is correct
50 Correct 133 ms 29776 KB Output is correct
51 Correct 134 ms 29808 KB Output is correct
52 Correct 115 ms 29704 KB Output is correct
53 Correct 122 ms 29776 KB Output is correct
54 Correct 172 ms 31792 KB Output is correct
55 Correct 177 ms 30964 KB Output is correct
56 Correct 154 ms 31632 KB Output is correct
57 Correct 1176 ms 61756 KB Output is correct
58 Correct 1171 ms 61880 KB Output is correct
59 Correct 1213 ms 57688 KB Output is correct
60 Correct 1158 ms 57624 KB Output is correct
61 Correct 1148 ms 57604 KB Output is correct
62 Correct 1071 ms 57596 KB Output is correct
63 Correct 697 ms 47872 KB Output is correct
64 Correct 773 ms 47832 KB Output is correct
65 Correct 1000 ms 53188 KB Output is correct
66 Correct 1028 ms 53224 KB Output is correct
67 Correct 1022 ms 53588 KB Output is correct
68 Correct 1151 ms 57924 KB Output is correct
69 Correct 1057 ms 57876 KB Output is correct
70 Correct 1068 ms 57104 KB Output is correct
71 Correct 1079 ms 57084 KB Output is correct
72 Correct 1075 ms 57168 KB Output is correct
73 Correct 662 ms 47332 KB Output is correct
74 Correct 712 ms 47380 KB Output is correct
75 Correct 733 ms 47420 KB Output is correct
76 Correct 722 ms 47600 KB Output is correct
77 Correct 809 ms 47328 KB Output is correct
78 Correct 1047 ms 57256 KB Output is correct
79 Correct 724 ms 51768 KB Output is correct
80 Correct 930 ms 56616 KB Output is correct