# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
380439 | 2021-03-21T19:18:25 Z | JerryLiu06 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++11 | 1678 ms | 97100 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<pair<int, int>, int> pii; #define pb push_back #define f first #define s second int N, M, A[1000010]; vector<pii> Q[1000010]; int tree[4000010], ans[1000010]; void update(int x, int l, int r, int pos, int val) { int mid = (l + r) / 2; if (r < pos || l > pos) return ; if (l == r) { tree[x] = val; return ; } update(2 * x, l, mid, pos, val); update(2 * x + 1, mid + 1, r, pos, val); tree[x] = max(tree[2 * x], tree[2 * x + 1]); } int query(int x, int l, int r, int tl, int tr) { int mid = (l + r) / 2; if (r < tl || l > tr) return 0; if (tl <= l && r <= tr) return tree[x]; return max(query(2 * x, l, mid, tl, tr), query(2 * x + 1, mid + 1, r, tl, tr)); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> M; for (int i = 1; i <= N; i++) cin >> A[i]; for (int i = 0; i < M; i++) { int A, B, M; cin >> A >> B >> M; Q[B].pb(pii {{A, M}, i}); } stack<int> CUR; for (int i = 1; i <= N; i++) { while (!CUR.empty() && A[CUR.top()] <= A[i]) CUR.pop(); if (!CUR.empty()) update(1, 1, N, CUR.top(), A[CUR.top()] + A[i]); CUR.push(i); for (pii X : Q[i]) { ans[X.s] = (query(1, 1, N, X.f.f, N) <= X.f.s); } } for (int i = 0; i < M; i++) cout << ans[i] << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 17 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23916 KB | Output is correct |
4 | Correct | 17 ms | 23916 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23916 KB | Output is correct |
7 | Correct | 17 ms | 23916 KB | Output is correct |
8 | Correct | 17 ms | 23916 KB | Output is correct |
9 | Correct | 17 ms | 23916 KB | Output is correct |
10 | Correct | 17 ms | 23916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 17 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23916 KB | Output is correct |
4 | Correct | 17 ms | 23916 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23916 KB | Output is correct |
7 | Correct | 17 ms | 23916 KB | Output is correct |
8 | Correct | 17 ms | 23916 KB | Output is correct |
9 | Correct | 17 ms | 23916 KB | Output is correct |
10 | Correct | 17 ms | 23916 KB | Output is correct |
11 | Correct | 19 ms | 24044 KB | Output is correct |
12 | Correct | 20 ms | 24172 KB | Output is correct |
13 | Correct | 20 ms | 24172 KB | Output is correct |
14 | Correct | 22 ms | 24172 KB | Output is correct |
15 | Correct | 22 ms | 24172 KB | Output is correct |
16 | Correct | 20 ms | 24172 KB | Output is correct |
17 | Correct | 20 ms | 24172 KB | Output is correct |
18 | Correct | 20 ms | 24172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1670 ms | 95596 KB | Output is correct |
2 | Correct | 1669 ms | 96612 KB | Output is correct |
3 | Correct | 1674 ms | 96380 KB | Output is correct |
4 | Correct | 1678 ms | 96820 KB | Output is correct |
5 | Correct | 1201 ms | 88344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 30188 KB | Output is correct |
2 | Correct | 128 ms | 29676 KB | Output is correct |
3 | Correct | 97 ms | 28908 KB | Output is correct |
4 | Correct | 98 ms | 29036 KB | Output is correct |
5 | Correct | 101 ms | 28908 KB | Output is correct |
6 | Correct | 82 ms | 28396 KB | Output is correct |
7 | Correct | 82 ms | 28396 KB | Output is correct |
8 | Correct | 100 ms | 28580 KB | Output is correct |
9 | Correct | 60 ms | 27300 KB | Output is correct |
10 | Correct | 96 ms | 28580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 17 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23916 KB | Output is correct |
4 | Correct | 17 ms | 23916 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23916 KB | Output is correct |
7 | Correct | 17 ms | 23916 KB | Output is correct |
8 | Correct | 17 ms | 23916 KB | Output is correct |
9 | Correct | 17 ms | 23916 KB | Output is correct |
10 | Correct | 17 ms | 23916 KB | Output is correct |
11 | Correct | 19 ms | 24044 KB | Output is correct |
12 | Correct | 20 ms | 24172 KB | Output is correct |
13 | Correct | 20 ms | 24172 KB | Output is correct |
14 | Correct | 22 ms | 24172 KB | Output is correct |
15 | Correct | 22 ms | 24172 KB | Output is correct |
16 | Correct | 20 ms | 24172 KB | Output is correct |
17 | Correct | 20 ms | 24172 KB | Output is correct |
18 | Correct | 20 ms | 24172 KB | Output is correct |
19 | Correct | 288 ms | 38796 KB | Output is correct |
20 | Correct | 277 ms | 38892 KB | Output is correct |
21 | Correct | 237 ms | 38140 KB | Output is correct |
22 | Correct | 236 ms | 38124 KB | Output is correct |
23 | Correct | 243 ms | 37996 KB | Output is correct |
24 | Correct | 185 ms | 35992 KB | Output is correct |
25 | Correct | 185 ms | 35820 KB | Output is correct |
26 | Correct | 215 ms | 36204 KB | Output is correct |
27 | Correct | 212 ms | 36332 KB | Output is correct |
28 | Correct | 208 ms | 36332 KB | Output is correct |
29 | Correct | 229 ms | 36716 KB | Output is correct |
30 | Correct | 212 ms | 36716 KB | Output is correct |
31 | Correct | 222 ms | 36588 KB | Output is correct |
32 | Correct | 218 ms | 36588 KB | Output is correct |
33 | Correct | 221 ms | 36588 KB | Output is correct |
34 | Correct | 170 ms | 35436 KB | Output is correct |
35 | Correct | 167 ms | 35436 KB | Output is correct |
36 | Correct | 165 ms | 35308 KB | Output is correct |
37 | Correct | 172 ms | 35384 KB | Output is correct |
38 | Correct | 167 ms | 35436 KB | Output is correct |
39 | Correct | 199 ms | 35620 KB | Output is correct |
40 | Correct | 162 ms | 33652 KB | Output is correct |
41 | Correct | 207 ms | 34464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 23788 KB | Output is correct |
2 | Correct | 17 ms | 23788 KB | Output is correct |
3 | Correct | 17 ms | 23916 KB | Output is correct |
4 | Correct | 17 ms | 23916 KB | Output is correct |
5 | Correct | 17 ms | 23788 KB | Output is correct |
6 | Correct | 17 ms | 23916 KB | Output is correct |
7 | Correct | 17 ms | 23916 KB | Output is correct |
8 | Correct | 17 ms | 23916 KB | Output is correct |
9 | Correct | 17 ms | 23916 KB | Output is correct |
10 | Correct | 17 ms | 23916 KB | Output is correct |
11 | Correct | 19 ms | 24044 KB | Output is correct |
12 | Correct | 20 ms | 24172 KB | Output is correct |
13 | Correct | 20 ms | 24172 KB | Output is correct |
14 | Correct | 22 ms | 24172 KB | Output is correct |
15 | Correct | 22 ms | 24172 KB | Output is correct |
16 | Correct | 20 ms | 24172 KB | Output is correct |
17 | Correct | 20 ms | 24172 KB | Output is correct |
18 | Correct | 20 ms | 24172 KB | Output is correct |
19 | Correct | 1670 ms | 95596 KB | Output is correct |
20 | Correct | 1669 ms | 96612 KB | Output is correct |
21 | Correct | 1674 ms | 96380 KB | Output is correct |
22 | Correct | 1678 ms | 96820 KB | Output is correct |
23 | Correct | 1201 ms | 88344 KB | Output is correct |
24 | Correct | 133 ms | 30188 KB | Output is correct |
25 | Correct | 128 ms | 29676 KB | Output is correct |
26 | Correct | 97 ms | 28908 KB | Output is correct |
27 | Correct | 98 ms | 29036 KB | Output is correct |
28 | Correct | 101 ms | 28908 KB | Output is correct |
29 | Correct | 82 ms | 28396 KB | Output is correct |
30 | Correct | 82 ms | 28396 KB | Output is correct |
31 | Correct | 100 ms | 28580 KB | Output is correct |
32 | Correct | 60 ms | 27300 KB | Output is correct |
33 | Correct | 96 ms | 28580 KB | Output is correct |
34 | Correct | 288 ms | 38796 KB | Output is correct |
35 | Correct | 277 ms | 38892 KB | Output is correct |
36 | Correct | 237 ms | 38140 KB | Output is correct |
37 | Correct | 236 ms | 38124 KB | Output is correct |
38 | Correct | 243 ms | 37996 KB | Output is correct |
39 | Correct | 185 ms | 35992 KB | Output is correct |
40 | Correct | 185 ms | 35820 KB | Output is correct |
41 | Correct | 215 ms | 36204 KB | Output is correct |
42 | Correct | 212 ms | 36332 KB | Output is correct |
43 | Correct | 208 ms | 36332 KB | Output is correct |
44 | Correct | 229 ms | 36716 KB | Output is correct |
45 | Correct | 212 ms | 36716 KB | Output is correct |
46 | Correct | 222 ms | 36588 KB | Output is correct |
47 | Correct | 218 ms | 36588 KB | Output is correct |
48 | Correct | 221 ms | 36588 KB | Output is correct |
49 | Correct | 170 ms | 35436 KB | Output is correct |
50 | Correct | 167 ms | 35436 KB | Output is correct |
51 | Correct | 165 ms | 35308 KB | Output is correct |
52 | Correct | 172 ms | 35384 KB | Output is correct |
53 | Correct | 167 ms | 35436 KB | Output is correct |
54 | Correct | 199 ms | 35620 KB | Output is correct |
55 | Correct | 162 ms | 33652 KB | Output is correct |
56 | Correct | 207 ms | 34464 KB | Output is correct |
57 | Correct | 1663 ms | 96876 KB | Output is correct |
58 | Correct | 1612 ms | 97100 KB | Output is correct |
59 | Correct | 1537 ms | 95256 KB | Output is correct |
60 | Correct | 1534 ms | 95164 KB | Output is correct |
61 | Correct | 1534 ms | 95276 KB | Output is correct |
62 | Correct | 1513 ms | 95212 KB | Output is correct |
63 | Correct | 903 ms | 83948 KB | Output is correct |
64 | Correct | 975 ms | 83812 KB | Output is correct |
65 | Correct | 1165 ms | 86928 KB | Output is correct |
66 | Correct | 1154 ms | 86936 KB | Output is correct |
67 | Correct | 1173 ms | 86896 KB | Output is correct |
68 | Correct | 1205 ms | 88684 KB | Output is correct |
69 | Correct | 1186 ms | 88668 KB | Output is correct |
70 | Correct | 1203 ms | 88400 KB | Output is correct |
71 | Correct | 1195 ms | 88376 KB | Output is correct |
72 | Correct | 1206 ms | 88316 KB | Output is correct |
73 | Correct | 771 ms | 79596 KB | Output is correct |
74 | Correct | 836 ms | 81088 KB | Output is correct |
75 | Correct | 830 ms | 79980 KB | Output is correct |
76 | Correct | 797 ms | 79980 KB | Output is correct |
77 | Correct | 839 ms | 79452 KB | Output is correct |
78 | Correct | 1131 ms | 83484 KB | Output is correct |
79 | Correct | 790 ms | 71684 KB | Output is correct |
80 | Correct | 1169 ms | 77968 KB | Output is correct |