# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
361390 | 2021-01-29T17:44:40 Z | pure_mem | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 1131 ms | 93992 KB |
#include <cstdio> #include <vector> #include <algorithm> #include <stack> #define X first #define Y second #define MP make_pair #define ll long long using namespace std; const int N = 1e6 + 3; int n, q, w[N], ans[N], fw[N]; vector< pair< pair<int, int>, int > > aybar[N]; void upd(int v, int val){ for(;v <= n;v |= v + 1) fw[v] = max(fw[v], val); } int get(int v){ int val = 0; for(;v >= 0;v = (v & (v + 1)) - 1) val = max(val, fw[v]); return val; } int main () { scanf("%d %d", &n, &q); for(int i = 1;i <= n;i++) scanf("%d", w + i); for(int i = 1, l, r, x;i <= q;i++){ scanf("%d %d %d", &l, &r, &x); aybar[l].push_back(MP(MP(r, x), i)); } stack<int> b; for(int i = n;i >= 1;i--){ while(!b.empty() && w[i] > w[b.top()]) upd(b.top(), w[b.top()] + w[i]), b.pop(); b.push(i); for(pair< pair<int, int>, int > tmp: aybar[i]) ans[tmp.Y] = get(tmp.X.X) <= tmp.X.Y;//, cerr << get(n - tmp.X.X + 1) << " " << tmp.Y << "\n"; } for(int i = 1;i <= q;i++) printf("%d\n", ans[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23788 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23788 KB | Output is correct |
7 | Correct | 16 ms | 23808 KB | Output is correct |
8 | Correct | 17 ms | 23788 KB | Output is correct |
9 | Correct | 16 ms | 23788 KB | Output is correct |
10 | Correct | 18 ms | 23788 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23788 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23788 KB | Output is correct |
7 | Correct | 16 ms | 23808 KB | Output is correct |
8 | Correct | 17 ms | 23788 KB | Output is correct |
9 | Correct | 16 ms | 23788 KB | Output is correct |
10 | Correct | 18 ms | 23788 KB | Output is correct |
11 | Correct | 18 ms | 24044 KB | Output is correct |
12 | Correct | 19 ms | 24044 KB | Output is correct |
13 | Correct | 19 ms | 24044 KB | Output is correct |
14 | Correct | 21 ms | 24172 KB | Output is correct |
15 | Correct | 25 ms | 24172 KB | Output is correct |
16 | Correct | 23 ms | 24044 KB | Output is correct |
17 | Correct | 19 ms | 24044 KB | Output is correct |
18 | Correct | 19 ms | 24044 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1115 ms | 59392 KB | Output is correct |
2 | Correct | 1088 ms | 92328 KB | Output is correct |
3 | Correct | 1105 ms | 92360 KB | Output is correct |
4 | Correct | 1074 ms | 92396 KB | Output is correct |
5 | Correct | 1043 ms | 92432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 89 ms | 27372 KB | Output is correct |
2 | Correct | 104 ms | 29292 KB | Output is correct |
3 | Correct | 83 ms | 29292 KB | Output is correct |
4 | Correct | 94 ms | 29420 KB | Output is correct |
5 | Correct | 90 ms | 29420 KB | Output is correct |
6 | Correct | 81 ms | 28780 KB | Output is correct |
7 | Correct | 71 ms | 28652 KB | Output is correct |
8 | Correct | 85 ms | 28708 KB | Output is correct |
9 | Correct | 59 ms | 27300 KB | Output is correct |
10 | Correct | 86 ms | 28804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23788 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23788 KB | Output is correct |
7 | Correct | 16 ms | 23808 KB | Output is correct |
8 | Correct | 17 ms | 23788 KB | Output is correct |
9 | Correct | 16 ms | 23788 KB | Output is correct |
10 | Correct | 18 ms | 23788 KB | Output is correct |
11 | Correct | 18 ms | 24044 KB | Output is correct |
12 | Correct | 19 ms | 24044 KB | Output is correct |
13 | Correct | 19 ms | 24044 KB | Output is correct |
14 | Correct | 21 ms | 24172 KB | Output is correct |
15 | Correct | 25 ms | 24172 KB | Output is correct |
16 | Correct | 23 ms | 24044 KB | Output is correct |
17 | Correct | 19 ms | 24044 KB | Output is correct |
18 | Correct | 19 ms | 24044 KB | Output is correct |
19 | Correct | 207 ms | 37636 KB | Output is correct |
20 | Correct | 214 ms | 37740 KB | Output is correct |
21 | Correct | 177 ms | 37100 KB | Output is correct |
22 | Correct | 172 ms | 37052 KB | Output is correct |
23 | Correct | 182 ms | 37100 KB | Output is correct |
24 | Correct | 163 ms | 36972 KB | Output is correct |
25 | Correct | 169 ms | 36972 KB | Output is correct |
26 | Correct | 177 ms | 37228 KB | Output is correct |
27 | Correct | 188 ms | 37228 KB | Output is correct |
28 | Correct | 187 ms | 37228 KB | Output is correct |
29 | Correct | 194 ms | 37740 KB | Output is correct |
30 | Correct | 201 ms | 37868 KB | Output is correct |
31 | Correct | 198 ms | 37612 KB | Output is correct |
32 | Correct | 198 ms | 37740 KB | Output is correct |
33 | Correct | 194 ms | 37612 KB | Output is correct |
34 | Correct | 152 ms | 36204 KB | Output is correct |
35 | Correct | 149 ms | 36076 KB | Output is correct |
36 | Correct | 147 ms | 35820 KB | Output is correct |
37 | Correct | 148 ms | 35820 KB | Output is correct |
38 | Correct | 152 ms | 35948 KB | Output is correct |
39 | Correct | 171 ms | 35492 KB | Output is correct |
40 | Correct | 149 ms | 33996 KB | Output is correct |
41 | Correct | 168 ms | 35108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 16 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23788 KB | Output is correct |
4 | Correct | 16 ms | 23788 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23788 KB | Output is correct |
7 | Correct | 16 ms | 23808 KB | Output is correct |
8 | Correct | 17 ms | 23788 KB | Output is correct |
9 | Correct | 16 ms | 23788 KB | Output is correct |
10 | Correct | 18 ms | 23788 KB | Output is correct |
11 | Correct | 18 ms | 24044 KB | Output is correct |
12 | Correct | 19 ms | 24044 KB | Output is correct |
13 | Correct | 19 ms | 24044 KB | Output is correct |
14 | Correct | 21 ms | 24172 KB | Output is correct |
15 | Correct | 25 ms | 24172 KB | Output is correct |
16 | Correct | 23 ms | 24044 KB | Output is correct |
17 | Correct | 19 ms | 24044 KB | Output is correct |
18 | Correct | 19 ms | 24044 KB | Output is correct |
19 | Correct | 1115 ms | 59392 KB | Output is correct |
20 | Correct | 1088 ms | 92328 KB | Output is correct |
21 | Correct | 1105 ms | 92360 KB | Output is correct |
22 | Correct | 1074 ms | 92396 KB | Output is correct |
23 | Correct | 1043 ms | 92432 KB | Output is correct |
24 | Correct | 89 ms | 27372 KB | Output is correct |
25 | Correct | 104 ms | 29292 KB | Output is correct |
26 | Correct | 83 ms | 29292 KB | Output is correct |
27 | Correct | 94 ms | 29420 KB | Output is correct |
28 | Correct | 90 ms | 29420 KB | Output is correct |
29 | Correct | 81 ms | 28780 KB | Output is correct |
30 | Correct | 71 ms | 28652 KB | Output is correct |
31 | Correct | 85 ms | 28708 KB | Output is correct |
32 | Correct | 59 ms | 27300 KB | Output is correct |
33 | Correct | 86 ms | 28804 KB | Output is correct |
34 | Correct | 207 ms | 37636 KB | Output is correct |
35 | Correct | 214 ms | 37740 KB | Output is correct |
36 | Correct | 177 ms | 37100 KB | Output is correct |
37 | Correct | 172 ms | 37052 KB | Output is correct |
38 | Correct | 182 ms | 37100 KB | Output is correct |
39 | Correct | 163 ms | 36972 KB | Output is correct |
40 | Correct | 169 ms | 36972 KB | Output is correct |
41 | Correct | 177 ms | 37228 KB | Output is correct |
42 | Correct | 188 ms | 37228 KB | Output is correct |
43 | Correct | 187 ms | 37228 KB | Output is correct |
44 | Correct | 194 ms | 37740 KB | Output is correct |
45 | Correct | 201 ms | 37868 KB | Output is correct |
46 | Correct | 198 ms | 37612 KB | Output is correct |
47 | Correct | 198 ms | 37740 KB | Output is correct |
48 | Correct | 194 ms | 37612 KB | Output is correct |
49 | Correct | 152 ms | 36204 KB | Output is correct |
50 | Correct | 149 ms | 36076 KB | Output is correct |
51 | Correct | 147 ms | 35820 KB | Output is correct |
52 | Correct | 148 ms | 35820 KB | Output is correct |
53 | Correct | 152 ms | 35948 KB | Output is correct |
54 | Correct | 171 ms | 35492 KB | Output is correct |
55 | Correct | 149 ms | 33996 KB | Output is correct |
56 | Correct | 168 ms | 35108 KB | Output is correct |
57 | Correct | 1131 ms | 93636 KB | Output is correct |
58 | Correct | 1121 ms | 93804 KB | Output is correct |
59 | Correct | 1066 ms | 91628 KB | Output is correct |
60 | Correct | 1075 ms | 91872 KB | Output is correct |
61 | Correct | 1077 ms | 91492 KB | Output is correct |
62 | Correct | 1059 ms | 91608 KB | Output is correct |
63 | Correct | 772 ms | 85264 KB | Output is correct |
64 | Correct | 765 ms | 85212 KB | Output is correct |
65 | Correct | 1016 ms | 91756 KB | Output is correct |
66 | Correct | 1018 ms | 91692 KB | Output is correct |
67 | Correct | 1014 ms | 91756 KB | Output is correct |
68 | Correct | 1053 ms | 93992 KB | Output is correct |
69 | Correct | 1061 ms | 93964 KB | Output is correct |
70 | Correct | 1045 ms | 93464 KB | Output is correct |
71 | Correct | 1101 ms | 93548 KB | Output is correct |
72 | Correct | 1048 ms | 93376 KB | Output is correct |
73 | Correct | 674 ms | 81388 KB | Output is correct |
74 | Correct | 691 ms | 82532 KB | Output is correct |
75 | Correct | 679 ms | 81900 KB | Output is correct |
76 | Correct | 686 ms | 81492 KB | Output is correct |
77 | Correct | 676 ms | 81724 KB | Output is correct |
78 | Correct | 924 ms | 83776 KB | Output is correct |
79 | Correct | 730 ms | 73264 KB | Output is correct |
80 | Correct | 906 ms | 81536 KB | Output is correct |