# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689800 | 2023-01-29T11:43:05 Z | nguyentunglam | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 833 ms | 94116 KB |
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 1e6 + 10; int a[N], k[N], bit[N], ans[N]; int n, m; vector<pair<int, int> > query[N]; void up(int pos, int val) { while (pos) { bit[pos] = max(bit[pos], val); pos -= pos & -pos; } } int get(int pos) { int ret = 0; while (pos <= n) { ret = max(ret, bit[pos]); pos += pos & -pos; } return ret; } int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= m; i++) { int l, r; cin >> l >> r >> k[i]; query[r].push_back({l, i}); } stack<int> st; for(int i = 1; i <= n; i++) { while (!st.empty() && a[st.top()] <= a[i]) st.pop(); if (!st.empty()) up(st.top(), a[st.top()] + a[i]); st.push(i); for(auto [l, id] : query[i]) ans[id] = get(l); } for(int i = 1; i <= m; i++) cout << (ans[i] <= k[i]) << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23852 KB | Output is correct |
4 | Correct | 13 ms | 23828 KB | Output is correct |
5 | Correct | 11 ms | 23764 KB | Output is correct |
6 | Correct | 14 ms | 23776 KB | Output is correct |
7 | Correct | 14 ms | 23828 KB | Output is correct |
8 | Correct | 12 ms | 23820 KB | Output is correct |
9 | Correct | 12 ms | 23820 KB | Output is correct |
10 | Correct | 12 ms | 23872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23852 KB | Output is correct |
4 | Correct | 13 ms | 23828 KB | Output is correct |
5 | Correct | 11 ms | 23764 KB | Output is correct |
6 | Correct | 14 ms | 23776 KB | Output is correct |
7 | Correct | 14 ms | 23828 KB | Output is correct |
8 | Correct | 12 ms | 23820 KB | Output is correct |
9 | Correct | 12 ms | 23820 KB | Output is correct |
10 | Correct | 12 ms | 23872 KB | Output is correct |
11 | Correct | 13 ms | 23948 KB | Output is correct |
12 | Correct | 14 ms | 24012 KB | Output is correct |
13 | Correct | 13 ms | 24020 KB | Output is correct |
14 | Correct | 16 ms | 24148 KB | Output is correct |
15 | Correct | 14 ms | 24060 KB | Output is correct |
16 | Correct | 14 ms | 24024 KB | Output is correct |
17 | Correct | 14 ms | 24004 KB | Output is correct |
18 | Correct | 14 ms | 24020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 783 ms | 83480 KB | Output is correct |
2 | Correct | 833 ms | 76700 KB | Output is correct |
3 | Correct | 826 ms | 93888 KB | Output is correct |
4 | Correct | 806 ms | 94116 KB | Output is correct |
5 | Correct | 799 ms | 90264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 27892 KB | Output is correct |
2 | Correct | 58 ms | 28588 KB | Output is correct |
3 | Correct | 60 ms | 28896 KB | Output is correct |
4 | Correct | 61 ms | 28972 KB | Output is correct |
5 | Correct | 57 ms | 29004 KB | Output is correct |
6 | Correct | 51 ms | 28164 KB | Output is correct |
7 | Correct | 52 ms | 28116 KB | Output is correct |
8 | Correct | 59 ms | 28536 KB | Output is correct |
9 | Correct | 41 ms | 27136 KB | Output is correct |
10 | Correct | 63 ms | 28572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23852 KB | Output is correct |
4 | Correct | 13 ms | 23828 KB | Output is correct |
5 | Correct | 11 ms | 23764 KB | Output is correct |
6 | Correct | 14 ms | 23776 KB | Output is correct |
7 | Correct | 14 ms | 23828 KB | Output is correct |
8 | Correct | 12 ms | 23820 KB | Output is correct |
9 | Correct | 12 ms | 23820 KB | Output is correct |
10 | Correct | 12 ms | 23872 KB | Output is correct |
11 | Correct | 13 ms | 23948 KB | Output is correct |
12 | Correct | 14 ms | 24012 KB | Output is correct |
13 | Correct | 13 ms | 24020 KB | Output is correct |
14 | Correct | 16 ms | 24148 KB | Output is correct |
15 | Correct | 14 ms | 24060 KB | Output is correct |
16 | Correct | 14 ms | 24024 KB | Output is correct |
17 | Correct | 14 ms | 24004 KB | Output is correct |
18 | Correct | 14 ms | 24020 KB | Output is correct |
19 | Correct | 139 ms | 35120 KB | Output is correct |
20 | Correct | 150 ms | 37688 KB | Output is correct |
21 | Correct | 129 ms | 36420 KB | Output is correct |
22 | Correct | 127 ms | 36404 KB | Output is correct |
23 | Correct | 119 ms | 36312 KB | Output is correct |
24 | Correct | 113 ms | 35300 KB | Output is correct |
25 | Correct | 110 ms | 35384 KB | Output is correct |
26 | Correct | 144 ms | 36052 KB | Output is correct |
27 | Correct | 129 ms | 36084 KB | Output is correct |
28 | Correct | 121 ms | 36232 KB | Output is correct |
29 | Correct | 141 ms | 36840 KB | Output is correct |
30 | Correct | 132 ms | 36912 KB | Output is correct |
31 | Correct | 136 ms | 36840 KB | Output is correct |
32 | Correct | 139 ms | 36796 KB | Output is correct |
33 | Correct | 127 ms | 36800 KB | Output is correct |
34 | Correct | 122 ms | 34992 KB | Output is correct |
35 | Correct | 106 ms | 34976 KB | Output is correct |
36 | Correct | 110 ms | 34824 KB | Output is correct |
37 | Correct | 102 ms | 34844 KB | Output is correct |
38 | Correct | 112 ms | 35012 KB | Output is correct |
39 | Correct | 122 ms | 35496 KB | Output is correct |
40 | Correct | 109 ms | 33748 KB | Output is correct |
41 | Correct | 115 ms | 34700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 23764 KB | Output is correct |
2 | Correct | 12 ms | 23764 KB | Output is correct |
3 | Correct | 12 ms | 23852 KB | Output is correct |
4 | Correct | 13 ms | 23828 KB | Output is correct |
5 | Correct | 11 ms | 23764 KB | Output is correct |
6 | Correct | 14 ms | 23776 KB | Output is correct |
7 | Correct | 14 ms | 23828 KB | Output is correct |
8 | Correct | 12 ms | 23820 KB | Output is correct |
9 | Correct | 12 ms | 23820 KB | Output is correct |
10 | Correct | 12 ms | 23872 KB | Output is correct |
11 | Correct | 13 ms | 23948 KB | Output is correct |
12 | Correct | 14 ms | 24012 KB | Output is correct |
13 | Correct | 13 ms | 24020 KB | Output is correct |
14 | Correct | 16 ms | 24148 KB | Output is correct |
15 | Correct | 14 ms | 24060 KB | Output is correct |
16 | Correct | 14 ms | 24024 KB | Output is correct |
17 | Correct | 14 ms | 24004 KB | Output is correct |
18 | Correct | 14 ms | 24020 KB | Output is correct |
19 | Correct | 783 ms | 83480 KB | Output is correct |
20 | Correct | 833 ms | 76700 KB | Output is correct |
21 | Correct | 826 ms | 93888 KB | Output is correct |
22 | Correct | 806 ms | 94116 KB | Output is correct |
23 | Correct | 799 ms | 90264 KB | Output is correct |
24 | Correct | 59 ms | 27892 KB | Output is correct |
25 | Correct | 58 ms | 28588 KB | Output is correct |
26 | Correct | 60 ms | 28896 KB | Output is correct |
27 | Correct | 61 ms | 28972 KB | Output is correct |
28 | Correct | 57 ms | 29004 KB | Output is correct |
29 | Correct | 51 ms | 28164 KB | Output is correct |
30 | Correct | 52 ms | 28116 KB | Output is correct |
31 | Correct | 59 ms | 28536 KB | Output is correct |
32 | Correct | 41 ms | 27136 KB | Output is correct |
33 | Correct | 63 ms | 28572 KB | Output is correct |
34 | Correct | 139 ms | 35120 KB | Output is correct |
35 | Correct | 150 ms | 37688 KB | Output is correct |
36 | Correct | 129 ms | 36420 KB | Output is correct |
37 | Correct | 127 ms | 36404 KB | Output is correct |
38 | Correct | 119 ms | 36312 KB | Output is correct |
39 | Correct | 113 ms | 35300 KB | Output is correct |
40 | Correct | 110 ms | 35384 KB | Output is correct |
41 | Correct | 144 ms | 36052 KB | Output is correct |
42 | Correct | 129 ms | 36084 KB | Output is correct |
43 | Correct | 121 ms | 36232 KB | Output is correct |
44 | Correct | 141 ms | 36840 KB | Output is correct |
45 | Correct | 132 ms | 36912 KB | Output is correct |
46 | Correct | 136 ms | 36840 KB | Output is correct |
47 | Correct | 139 ms | 36796 KB | Output is correct |
48 | Correct | 127 ms | 36800 KB | Output is correct |
49 | Correct | 122 ms | 34992 KB | Output is correct |
50 | Correct | 106 ms | 34976 KB | Output is correct |
51 | Correct | 110 ms | 34824 KB | Output is correct |
52 | Correct | 102 ms | 34844 KB | Output is correct |
53 | Correct | 112 ms | 35012 KB | Output is correct |
54 | Correct | 122 ms | 35496 KB | Output is correct |
55 | Correct | 109 ms | 33748 KB | Output is correct |
56 | Correct | 115 ms | 34700 KB | Output is correct |
57 | Correct | 798 ms | 93796 KB | Output is correct |
58 | Correct | 827 ms | 93820 KB | Output is correct |
59 | Correct | 745 ms | 90952 KB | Output is correct |
60 | Correct | 752 ms | 90884 KB | Output is correct |
61 | Correct | 772 ms | 72392 KB | Output is correct |
62 | Correct | 797 ms | 90836 KB | Output is correct |
63 | Correct | 506 ms | 81564 KB | Output is correct |
64 | Correct | 508 ms | 81576 KB | Output is correct |
65 | Correct | 705 ms | 86696 KB | Output is correct |
66 | Correct | 714 ms | 86740 KB | Output is correct |
67 | Correct | 716 ms | 86824 KB | Output is correct |
68 | Correct | 763 ms | 89704 KB | Output is correct |
69 | Correct | 746 ms | 89688 KB | Output is correct |
70 | Correct | 745 ms | 89264 KB | Output is correct |
71 | Correct | 787 ms | 89364 KB | Output is correct |
72 | Correct | 792 ms | 89404 KB | Output is correct |
73 | Correct | 472 ms | 78556 KB | Output is correct |
74 | Correct | 493 ms | 79264 KB | Output is correct |
75 | Correct | 468 ms | 78408 KB | Output is correct |
76 | Correct | 472 ms | 78444 KB | Output is correct |
77 | Correct | 476 ms | 78348 KB | Output is correct |
78 | Correct | 670 ms | 83116 KB | Output is correct |
79 | Correct | 531 ms | 72804 KB | Output is correct |
80 | Correct | 654 ms | 62288 KB | Output is correct |