# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
257140 | 2020-08-03T16:10:28 Z | BThero | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 1393 ms | 114096 KB |
// chrono::system_clock::now().time_since_epoch().count() #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; const int MAXN = (int)1e6 + 5; vector<array<int, 3>> que[MAXN]; vector<int> V[MAXN]; int prv[MAXN]; int arr[MAXN]; int n, q; int fenw[MAXN]; int ans[MAXN]; int prefMax(int p) { int ret = 0; for (; p > 0; --p) { ret = max(ret, fenw[p]); p &= (p + 1); } return ret; } void fenwUpd(int p, int x) { for (; p <= n; p |= (p + 1)) { fenw[p] = max(fenw[p], x); } } void solve() { scanf("%d %d", &n, &q); for (int i = 1; i <= n; ++i) { scanf("%d", &arr[i]); } vector<int> vec; for (int i = 1; i <= n; ++i) { while (!vec.empty() && arr[vec.back()] <= arr[i]) { vec.pop_back(); } prv[i] = (vec.empty() ? 0 : vec.back()); V[prv[i]].pb(i); vec.pb(i); } for (int i = 1; i <= q; ++i) { int l, r, k; scanf("%d %d %d", &l, &r, &k); que[l].pb({r, k, i}); } for (int l = n; l > 0; --l) { for (int idx : V[l]) { fenwUpd(idx, arr[idx] + arr[l]); } for (auto &[r, k, id] : que[l]) { ans[id] = (prefMax(r) <= k); } } for (int i = 1; i <= q; ++i) { printf("%d\n", ans[i]); } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47352 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 31 ms | 47352 KB | Output is correct |
6 | Correct | 29 ms | 47360 KB | Output is correct |
7 | Correct | 30 ms | 47360 KB | Output is correct |
8 | Correct | 30 ms | 47352 KB | Output is correct |
9 | Correct | 29 ms | 47360 KB | Output is correct |
10 | Correct | 31 ms | 47352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47352 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 31 ms | 47352 KB | Output is correct |
6 | Correct | 29 ms | 47360 KB | Output is correct |
7 | Correct | 30 ms | 47360 KB | Output is correct |
8 | Correct | 30 ms | 47352 KB | Output is correct |
9 | Correct | 29 ms | 47360 KB | Output is correct |
10 | Correct | 31 ms | 47352 KB | Output is correct |
11 | Correct | 32 ms | 47480 KB | Output is correct |
12 | Correct | 42 ms | 47608 KB | Output is correct |
13 | Correct | 33 ms | 47616 KB | Output is correct |
14 | Correct | 33 ms | 47736 KB | Output is correct |
15 | Correct | 34 ms | 47736 KB | Output is correct |
16 | Correct | 32 ms | 47608 KB | Output is correct |
17 | Correct | 32 ms | 47608 KB | Output is correct |
18 | Correct | 32 ms | 47608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1241 ms | 112120 KB | Output is correct |
2 | Correct | 1355 ms | 105464 KB | Output is correct |
3 | Correct | 1270 ms | 105512 KB | Output is correct |
4 | Correct | 1261 ms | 105336 KB | Output is correct |
5 | Correct | 1142 ms | 89180 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 135 ms | 54908 KB | Output is correct |
2 | Correct | 120 ms | 54648 KB | Output is correct |
3 | Correct | 116 ms | 53104 KB | Output is correct |
4 | Correct | 117 ms | 53228 KB | Output is correct |
5 | Correct | 113 ms | 53484 KB | Output is correct |
6 | Correct | 87 ms | 52688 KB | Output is correct |
7 | Correct | 91 ms | 52716 KB | Output is correct |
8 | Correct | 102 ms | 52908 KB | Output is correct |
9 | Correct | 78 ms | 50736 KB | Output is correct |
10 | Correct | 106 ms | 52780 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47352 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 31 ms | 47352 KB | Output is correct |
6 | Correct | 29 ms | 47360 KB | Output is correct |
7 | Correct | 30 ms | 47360 KB | Output is correct |
8 | Correct | 30 ms | 47352 KB | Output is correct |
9 | Correct | 29 ms | 47360 KB | Output is correct |
10 | Correct | 31 ms | 47352 KB | Output is correct |
11 | Correct | 32 ms | 47480 KB | Output is correct |
12 | Correct | 42 ms | 47608 KB | Output is correct |
13 | Correct | 33 ms | 47616 KB | Output is correct |
14 | Correct | 33 ms | 47736 KB | Output is correct |
15 | Correct | 34 ms | 47736 KB | Output is correct |
16 | Correct | 32 ms | 47608 KB | Output is correct |
17 | Correct | 32 ms | 47608 KB | Output is correct |
18 | Correct | 32 ms | 47608 KB | Output is correct |
19 | Correct | 275 ms | 65144 KB | Output is correct |
20 | Correct | 249 ms | 65144 KB | Output is correct |
21 | Correct | 229 ms | 64492 KB | Output is correct |
22 | Correct | 218 ms | 64504 KB | Output is correct |
23 | Correct | 222 ms | 64632 KB | Output is correct |
24 | Correct | 194 ms | 61136 KB | Output is correct |
25 | Correct | 187 ms | 61160 KB | Output is correct |
26 | Correct | 212 ms | 61420 KB | Output is correct |
27 | Correct | 226 ms | 61548 KB | Output is correct |
28 | Correct | 211 ms | 61420 KB | Output is correct |
29 | Correct | 254 ms | 62060 KB | Output is correct |
30 | Correct | 230 ms | 61932 KB | Output is correct |
31 | Correct | 225 ms | 61928 KB | Output is correct |
32 | Correct | 238 ms | 61932 KB | Output is correct |
33 | Correct | 231 ms | 61932 KB | Output is correct |
34 | Correct | 177 ms | 60392 KB | Output is correct |
35 | Correct | 178 ms | 60400 KB | Output is correct |
36 | Correct | 176 ms | 60140 KB | Output is correct |
37 | Correct | 178 ms | 60268 KB | Output is correct |
38 | Correct | 178 ms | 60396 KB | Output is correct |
39 | Correct | 192 ms | 60904 KB | Output is correct |
40 | Correct | 164 ms | 58080 KB | Output is correct |
41 | Correct | 217 ms | 59752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 47352 KB | Output is correct |
2 | Correct | 36 ms | 47360 KB | Output is correct |
3 | Correct | 34 ms | 47352 KB | Output is correct |
4 | Correct | 33 ms | 47360 KB | Output is correct |
5 | Correct | 31 ms | 47352 KB | Output is correct |
6 | Correct | 29 ms | 47360 KB | Output is correct |
7 | Correct | 30 ms | 47360 KB | Output is correct |
8 | Correct | 30 ms | 47352 KB | Output is correct |
9 | Correct | 29 ms | 47360 KB | Output is correct |
10 | Correct | 31 ms | 47352 KB | Output is correct |
11 | Correct | 32 ms | 47480 KB | Output is correct |
12 | Correct | 42 ms | 47608 KB | Output is correct |
13 | Correct | 33 ms | 47616 KB | Output is correct |
14 | Correct | 33 ms | 47736 KB | Output is correct |
15 | Correct | 34 ms | 47736 KB | Output is correct |
16 | Correct | 32 ms | 47608 KB | Output is correct |
17 | Correct | 32 ms | 47608 KB | Output is correct |
18 | Correct | 32 ms | 47608 KB | Output is correct |
19 | Correct | 1241 ms | 112120 KB | Output is correct |
20 | Correct | 1355 ms | 105464 KB | Output is correct |
21 | Correct | 1270 ms | 105512 KB | Output is correct |
22 | Correct | 1261 ms | 105336 KB | Output is correct |
23 | Correct | 1142 ms | 89180 KB | Output is correct |
24 | Correct | 135 ms | 54908 KB | Output is correct |
25 | Correct | 120 ms | 54648 KB | Output is correct |
26 | Correct | 116 ms | 53104 KB | Output is correct |
27 | Correct | 117 ms | 53228 KB | Output is correct |
28 | Correct | 113 ms | 53484 KB | Output is correct |
29 | Correct | 87 ms | 52688 KB | Output is correct |
30 | Correct | 91 ms | 52716 KB | Output is correct |
31 | Correct | 102 ms | 52908 KB | Output is correct |
32 | Correct | 78 ms | 50736 KB | Output is correct |
33 | Correct | 106 ms | 52780 KB | Output is correct |
34 | Correct | 275 ms | 65144 KB | Output is correct |
35 | Correct | 249 ms | 65144 KB | Output is correct |
36 | Correct | 229 ms | 64492 KB | Output is correct |
37 | Correct | 218 ms | 64504 KB | Output is correct |
38 | Correct | 222 ms | 64632 KB | Output is correct |
39 | Correct | 194 ms | 61136 KB | Output is correct |
40 | Correct | 187 ms | 61160 KB | Output is correct |
41 | Correct | 212 ms | 61420 KB | Output is correct |
42 | Correct | 226 ms | 61548 KB | Output is correct |
43 | Correct | 211 ms | 61420 KB | Output is correct |
44 | Correct | 254 ms | 62060 KB | Output is correct |
45 | Correct | 230 ms | 61932 KB | Output is correct |
46 | Correct | 225 ms | 61928 KB | Output is correct |
47 | Correct | 238 ms | 61932 KB | Output is correct |
48 | Correct | 231 ms | 61932 KB | Output is correct |
49 | Correct | 177 ms | 60392 KB | Output is correct |
50 | Correct | 178 ms | 60400 KB | Output is correct |
51 | Correct | 176 ms | 60140 KB | Output is correct |
52 | Correct | 178 ms | 60268 KB | Output is correct |
53 | Correct | 178 ms | 60396 KB | Output is correct |
54 | Correct | 192 ms | 60904 KB | Output is correct |
55 | Correct | 164 ms | 58080 KB | Output is correct |
56 | Correct | 217 ms | 59752 KB | Output is correct |
57 | Correct | 1380 ms | 114040 KB | Output is correct |
58 | Correct | 1300 ms | 114096 KB | Output is correct |
59 | Correct | 1354 ms | 111864 KB | Output is correct |
60 | Correct | 1393 ms | 111868 KB | Output is correct |
61 | Correct | 1383 ms | 111868 KB | Output is correct |
62 | Correct | 1232 ms | 111864 KB | Output is correct |
63 | Correct | 814 ms | 91232 KB | Output is correct |
64 | Correct | 823 ms | 91484 KB | Output is correct |
65 | Correct | 1223 ms | 95640 KB | Output is correct |
66 | Correct | 1206 ms | 95580 KB | Output is correct |
67 | Correct | 1240 ms | 95708 KB | Output is correct |
68 | Correct | 1230 ms | 97756 KB | Output is correct |
69 | Correct | 1154 ms | 97628 KB | Output is correct |
70 | Correct | 1142 ms | 97500 KB | Output is correct |
71 | Correct | 1165 ms | 97372 KB | Output is correct |
72 | Correct | 1202 ms | 97288 KB | Output is correct |
73 | Correct | 714 ms | 89820 KB | Output is correct |
74 | Correct | 717 ms | 89996 KB | Output is correct |
75 | Correct | 779 ms | 89692 KB | Output is correct |
76 | Correct | 782 ms | 89568 KB | Output is correct |
77 | Correct | 716 ms | 89436 KB | Output is correct |
78 | Correct | 1038 ms | 96860 KB | Output is correct |
79 | Correct | 779 ms | 99156 KB | Output is correct |
80 | Correct | 1046 ms | 93192 KB | Output is correct |