# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
377235 | 2021-03-13T13:52:17 Z | ntabc05101 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 2037 ms | 106724 KB |
#ifndef LOCAL #define NDEBUG 1 #endif // LOCAL #include<bits/stdc++.h> #define taskname "" #define f first #define s second const int max_n=2000000; int nodes[max_n<<2]; int L[max_n<<2], H[max_n<<2]; void buildRange(int node, int low, int high) { L[node]=low, H[node]=high; if (low==high) { return ; } int mid=low+high>>1; buildRange(node<<1, low, mid); buildRange(node<<1|1, mid+1, high); } void update(int node, int posq, int value) { if (L[node]==H[node]) { nodes[node]=std::max(nodes[node], value); return ; } if (posq>H[node<<1]) { update(node<<1|1, posq, value); } else { update(node<<1, posq, value); } nodes[node]=std::max(nodes[node<<1], nodes[node<<1|1]); } int get(int node, int leftq, int rightq) { if (leftq>H[node] or rightq<L[node]) { return 0; } if (leftq<=L[node] and rightq>=H[node]) { return nodes[node]; } return std::max(get(node<<1, leftq, rightq), get(node<<1|1, leftq, rightq)); } int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, m; std::cin>>n>>m; int w[n]; for (int i=0; i<n; ++i) { std::cin>>w[i]; } std::vector< std::pair< std::pair<int, int>, int > > q[n]; for (int i=0; i<m; ++i) { int left, right, k; std::cin>>left>>right>>k; --left, --right; q[right].push_back({{left, k}, i}); } bool result[m]; buildRange(1, 0, n-1); std::deque<int> deq; for (int i=0; i<n; ++i) { while (!deq.empty() and w[deq.back()]<=w[i]) { deq.pop_back(); } if (!deq.empty()) { update(1, deq.back(), w[deq.back()]+w[i]); } deq.push_back(i); for (auto& Q: q[i]) { result[Q.s]=(get(1, Q.f.f, i)<=Q.f.s); } } for (int i=0; i<m; ++i) { std::cout<<result[i]<<"\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 3 ms | 620 KB | Output is correct |
12 | Correct | 4 ms | 876 KB | Output is correct |
13 | Correct | 5 ms | 876 KB | Output is correct |
14 | Correct | 8 ms | 1004 KB | Output is correct |
15 | Correct | 7 ms | 876 KB | Output is correct |
16 | Correct | 7 ms | 876 KB | Output is correct |
17 | Correct | 4 ms | 748 KB | Output is correct |
18 | Correct | 4 ms | 876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2004 ms | 77132 KB | Output is correct |
2 | Correct | 2011 ms | 104792 KB | Output is correct |
3 | Correct | 2037 ms | 106724 KB | Output is correct |
4 | Correct | 2013 ms | 104832 KB | Output is correct |
5 | Correct | 1695 ms | 96676 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 133 ms | 8684 KB | Output is correct |
2 | Correct | 113 ms | 8556 KB | Output is correct |
3 | Correct | 111 ms | 7660 KB | Output is correct |
4 | Correct | 111 ms | 7660 KB | Output is correct |
5 | Correct | 109 ms | 7788 KB | Output is correct |
6 | Correct | 81 ms | 7404 KB | Output is correct |
7 | Correct | 84 ms | 7276 KB | Output is correct |
8 | Correct | 104 ms | 7588 KB | Output is correct |
9 | Correct | 46 ms | 2340 KB | Output is correct |
10 | Correct | 95 ms | 7588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 3 ms | 620 KB | Output is correct |
12 | Correct | 4 ms | 876 KB | Output is correct |
13 | Correct | 5 ms | 876 KB | Output is correct |
14 | Correct | 8 ms | 1004 KB | Output is correct |
15 | Correct | 7 ms | 876 KB | Output is correct |
16 | Correct | 7 ms | 876 KB | Output is correct |
17 | Correct | 4 ms | 748 KB | Output is correct |
18 | Correct | 4 ms | 876 KB | Output is correct |
19 | Correct | 345 ms | 17052 KB | Output is correct |
20 | Correct | 307 ms | 23404 KB | Output is correct |
21 | Correct | 258 ms | 22900 KB | Output is correct |
22 | Correct | 257 ms | 22764 KB | Output is correct |
23 | Correct | 255 ms | 22764 KB | Output is correct |
24 | Correct | 211 ms | 20588 KB | Output is correct |
25 | Correct | 240 ms | 20588 KB | Output is correct |
26 | Correct | 271 ms | 20972 KB | Output is correct |
27 | Correct | 261 ms | 20972 KB | Output is correct |
28 | Correct | 243 ms | 20972 KB | Output is correct |
29 | Correct | 261 ms | 21484 KB | Output is correct |
30 | Correct | 278 ms | 21484 KB | Output is correct |
31 | Correct | 281 ms | 21388 KB | Output is correct |
32 | Correct | 273 ms | 21356 KB | Output is correct |
33 | Correct | 277 ms | 21356 KB | Output is correct |
34 | Correct | 197 ms | 20268 KB | Output is correct |
35 | Correct | 188 ms | 20204 KB | Output is correct |
36 | Correct | 191 ms | 19948 KB | Output is correct |
37 | Correct | 187 ms | 19948 KB | Output is correct |
38 | Correct | 190 ms | 20076 KB | Output is correct |
39 | Correct | 239 ms | 20260 KB | Output is correct |
40 | Correct | 175 ms | 14624 KB | Output is correct |
41 | Correct | 222 ms | 19360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 3 ms | 620 KB | Output is correct |
12 | Correct | 4 ms | 876 KB | Output is correct |
13 | Correct | 5 ms | 876 KB | Output is correct |
14 | Correct | 8 ms | 1004 KB | Output is correct |
15 | Correct | 7 ms | 876 KB | Output is correct |
16 | Correct | 7 ms | 876 KB | Output is correct |
17 | Correct | 4 ms | 748 KB | Output is correct |
18 | Correct | 4 ms | 876 KB | Output is correct |
19 | Correct | 2004 ms | 77132 KB | Output is correct |
20 | Correct | 2011 ms | 104792 KB | Output is correct |
21 | Correct | 2037 ms | 106724 KB | Output is correct |
22 | Correct | 2013 ms | 104832 KB | Output is correct |
23 | Correct | 1695 ms | 96676 KB | Output is correct |
24 | Correct | 133 ms | 8684 KB | Output is correct |
25 | Correct | 113 ms | 8556 KB | Output is correct |
26 | Correct | 111 ms | 7660 KB | Output is correct |
27 | Correct | 111 ms | 7660 KB | Output is correct |
28 | Correct | 109 ms | 7788 KB | Output is correct |
29 | Correct | 81 ms | 7404 KB | Output is correct |
30 | Correct | 84 ms | 7276 KB | Output is correct |
31 | Correct | 104 ms | 7588 KB | Output is correct |
32 | Correct | 46 ms | 2340 KB | Output is correct |
33 | Correct | 95 ms | 7588 KB | Output is correct |
34 | Correct | 345 ms | 17052 KB | Output is correct |
35 | Correct | 307 ms | 23404 KB | Output is correct |
36 | Correct | 258 ms | 22900 KB | Output is correct |
37 | Correct | 257 ms | 22764 KB | Output is correct |
38 | Correct | 255 ms | 22764 KB | Output is correct |
39 | Correct | 211 ms | 20588 KB | Output is correct |
40 | Correct | 240 ms | 20588 KB | Output is correct |
41 | Correct | 271 ms | 20972 KB | Output is correct |
42 | Correct | 261 ms | 20972 KB | Output is correct |
43 | Correct | 243 ms | 20972 KB | Output is correct |
44 | Correct | 261 ms | 21484 KB | Output is correct |
45 | Correct | 278 ms | 21484 KB | Output is correct |
46 | Correct | 281 ms | 21388 KB | Output is correct |
47 | Correct | 273 ms | 21356 KB | Output is correct |
48 | Correct | 277 ms | 21356 KB | Output is correct |
49 | Correct | 197 ms | 20268 KB | Output is correct |
50 | Correct | 188 ms | 20204 KB | Output is correct |
51 | Correct | 191 ms | 19948 KB | Output is correct |
52 | Correct | 187 ms | 19948 KB | Output is correct |
53 | Correct | 190 ms | 20076 KB | Output is correct |
54 | Correct | 239 ms | 20260 KB | Output is correct |
55 | Correct | 175 ms | 14624 KB | Output is correct |
56 | Correct | 222 ms | 19360 KB | Output is correct |
57 | Correct | 1989 ms | 92684 KB | Output is correct |
58 | Correct | 1995 ms | 93864 KB | Output is correct |
59 | Correct | 1841 ms | 92396 KB | Output is correct |
60 | Correct | 1837 ms | 90464 KB | Output is correct |
61 | Correct | 1861 ms | 91388 KB | Output is correct |
62 | Correct | 1844 ms | 89576 KB | Output is correct |
63 | Correct | 1127 ms | 81548 KB | Output is correct |
64 | Correct | 1146 ms | 83948 KB | Output is correct |
65 | Correct | 1584 ms | 81640 KB | Output is correct |
66 | Correct | 1526 ms | 83436 KB | Output is correct |
67 | Correct | 1563 ms | 83948 KB | Output is correct |
68 | Correct | 1665 ms | 85316 KB | Output is correct |
69 | Correct | 1628 ms | 85524 KB | Output is correct |
70 | Correct | 1642 ms | 85128 KB | Output is correct |
71 | Correct | 1740 ms | 85092 KB | Output is correct |
72 | Correct | 1652 ms | 85064 KB | Output is correct |
73 | Correct | 983 ms | 81792 KB | Output is correct |
74 | Correct | 1030 ms | 81848 KB | Output is correct |
75 | Correct | 976 ms | 81824 KB | Output is correct |
76 | Correct | 1006 ms | 75660 KB | Output is correct |
77 | Correct | 960 ms | 80920 KB | Output is correct |
78 | Correct | 1440 ms | 92432 KB | Output is correct |
79 | Correct | 1016 ms | 65728 KB | Output is correct |
80 | Correct | 1386 ms | 91540 KB | Output is correct |