답안 #197407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197407 2020-01-21T04:43:14 Z IOrtroiii Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1329 ms 96100 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1 << 20;

int N, Q;
int A[MAXN];
vector<tuple<int, int, int>> qs[MAXN];
int tr[MAXN * 2];
bool ans[MAXN];

void update(int v, int val) {
   v += MAXN;
   tr[v] = max(tr[v], val);
   for (v >>= 1; v > 0; v >>= 1) {
      tr[v] = max(tr[v << 1], tr[v << 1 | 1]);
   }
}

int get(int l, int r) {
   int ans = 0;
   for (l += MAXN, r += MAXN; l <= r; l >>= 1, r >>= 1) {
      if (l & 1) ans = max(ans, tr[l++]);
      if (!(r & 1)) ans = max(ans, tr[r--]);
   }
   return ans;
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> N >> Q;
   for (int i = 1; i <= N; ++i) {
      cin >> A[i];
   }
   for (int i = 1; i <= Q; ++i) {
      int l, r, k;
      cin >> l >> r >> k;
      qs[l].emplace_back(r, k, i);
   }
   vector<int> st;
   for (int i = N; i > 0; --i) {
      while (!st.empty() && A[i] > A[st.back()]) {
         update(st.back(), A[i] + A[st.back()]);
         st.pop_back();
      }
      st.emplace_back(i);
      for (auto q : qs[i]) {
         ans[get<2>(q)] = get(i, get<0>(q)) <= get<1>(q);
      }
   }
   for (int i = 1; i <= Q; ++i) {
      cout << ans[i] << "\n";
   }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 25188 KB Output is correct
2 Correct 25 ms 24956 KB Output is correct
3 Correct 25 ms 25080 KB Output is correct
4 Correct 25 ms 25080 KB Output is correct
5 Correct 25 ms 25080 KB Output is correct
6 Correct 25 ms 25080 KB Output is correct
7 Correct 25 ms 25080 KB Output is correct
8 Correct 25 ms 25080 KB Output is correct
9 Correct 26 ms 25080 KB Output is correct
10 Correct 26 ms 25080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 25188 KB Output is correct
2 Correct 25 ms 24956 KB Output is correct
3 Correct 25 ms 25080 KB Output is correct
4 Correct 25 ms 25080 KB Output is correct
5 Correct 25 ms 25080 KB Output is correct
6 Correct 25 ms 25080 KB Output is correct
7 Correct 25 ms 25080 KB Output is correct
8 Correct 25 ms 25080 KB Output is correct
9 Correct 26 ms 25080 KB Output is correct
10 Correct 26 ms 25080 KB Output is correct
11 Correct 27 ms 25208 KB Output is correct
12 Correct 31 ms 25336 KB Output is correct
13 Correct 28 ms 25336 KB Output is correct
14 Correct 30 ms 25436 KB Output is correct
15 Correct 30 ms 25464 KB Output is correct
16 Correct 29 ms 25340 KB Output is correct
17 Correct 30 ms 25268 KB Output is correct
18 Correct 29 ms 25336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1297 ms 93420 KB Output is correct
2 Correct 1300 ms 94576 KB Output is correct
3 Correct 1306 ms 94328 KB Output is correct
4 Correct 1293 ms 94408 KB Output is correct
5 Correct 1205 ms 90840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 30800 KB Output is correct
2 Correct 109 ms 30500 KB Output is correct
3 Correct 115 ms 30324 KB Output is correct
4 Correct 118 ms 30444 KB Output is correct
5 Correct 117 ms 30476 KB Output is correct
6 Correct 88 ms 29936 KB Output is correct
7 Correct 87 ms 29808 KB Output is correct
8 Correct 109 ms 30252 KB Output is correct
9 Correct 69 ms 28208 KB Output is correct
10 Correct 106 ms 30180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 25188 KB Output is correct
2 Correct 25 ms 24956 KB Output is correct
3 Correct 25 ms 25080 KB Output is correct
4 Correct 25 ms 25080 KB Output is correct
5 Correct 25 ms 25080 KB Output is correct
6 Correct 25 ms 25080 KB Output is correct
7 Correct 25 ms 25080 KB Output is correct
8 Correct 25 ms 25080 KB Output is correct
9 Correct 26 ms 25080 KB Output is correct
10 Correct 26 ms 25080 KB Output is correct
11 Correct 27 ms 25208 KB Output is correct
12 Correct 31 ms 25336 KB Output is correct
13 Correct 28 ms 25336 KB Output is correct
14 Correct 30 ms 25436 KB Output is correct
15 Correct 30 ms 25464 KB Output is correct
16 Correct 29 ms 25340 KB Output is correct
17 Correct 30 ms 25268 KB Output is correct
18 Correct 29 ms 25336 KB Output is correct
19 Correct 263 ms 39396 KB Output is correct
20 Correct 259 ms 39164 KB Output is correct
21 Correct 220 ms 38520 KB Output is correct
22 Correct 221 ms 38604 KB Output is correct
23 Correct 230 ms 38544 KB Output is correct
24 Correct 199 ms 37608 KB Output is correct
25 Correct 195 ms 37612 KB Output is correct
26 Correct 228 ms 37940 KB Output is correct
27 Correct 228 ms 37864 KB Output is correct
28 Correct 232 ms 38000 KB Output is correct
29 Correct 245 ms 38356 KB Output is correct
30 Correct 244 ms 38520 KB Output is correct
31 Correct 248 ms 38376 KB Output is correct
32 Correct 244 ms 38280 KB Output is correct
33 Correct 263 ms 38476 KB Output is correct
34 Correct 187 ms 36896 KB Output is correct
35 Correct 177 ms 36840 KB Output is correct
36 Correct 169 ms 36696 KB Output is correct
37 Correct 170 ms 36756 KB Output is correct
38 Correct 176 ms 37072 KB Output is correct
39 Correct 236 ms 37040 KB Output is correct
40 Correct 182 ms 35320 KB Output is correct
41 Correct 203 ms 36520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 25188 KB Output is correct
2 Correct 25 ms 24956 KB Output is correct
3 Correct 25 ms 25080 KB Output is correct
4 Correct 25 ms 25080 KB Output is correct
5 Correct 25 ms 25080 KB Output is correct
6 Correct 25 ms 25080 KB Output is correct
7 Correct 25 ms 25080 KB Output is correct
8 Correct 25 ms 25080 KB Output is correct
9 Correct 26 ms 25080 KB Output is correct
10 Correct 26 ms 25080 KB Output is correct
11 Correct 27 ms 25208 KB Output is correct
12 Correct 31 ms 25336 KB Output is correct
13 Correct 28 ms 25336 KB Output is correct
14 Correct 30 ms 25436 KB Output is correct
15 Correct 30 ms 25464 KB Output is correct
16 Correct 29 ms 25340 KB Output is correct
17 Correct 30 ms 25268 KB Output is correct
18 Correct 29 ms 25336 KB Output is correct
19 Correct 1297 ms 93420 KB Output is correct
20 Correct 1300 ms 94576 KB Output is correct
21 Correct 1306 ms 94328 KB Output is correct
22 Correct 1293 ms 94408 KB Output is correct
23 Correct 1205 ms 90840 KB Output is correct
24 Correct 123 ms 30800 KB Output is correct
25 Correct 109 ms 30500 KB Output is correct
26 Correct 115 ms 30324 KB Output is correct
27 Correct 118 ms 30444 KB Output is correct
28 Correct 117 ms 30476 KB Output is correct
29 Correct 88 ms 29936 KB Output is correct
30 Correct 87 ms 29808 KB Output is correct
31 Correct 109 ms 30252 KB Output is correct
32 Correct 69 ms 28208 KB Output is correct
33 Correct 106 ms 30180 KB Output is correct
34 Correct 263 ms 39396 KB Output is correct
35 Correct 259 ms 39164 KB Output is correct
36 Correct 220 ms 38520 KB Output is correct
37 Correct 221 ms 38604 KB Output is correct
38 Correct 230 ms 38544 KB Output is correct
39 Correct 199 ms 37608 KB Output is correct
40 Correct 195 ms 37612 KB Output is correct
41 Correct 228 ms 37940 KB Output is correct
42 Correct 228 ms 37864 KB Output is correct
43 Correct 232 ms 38000 KB Output is correct
44 Correct 245 ms 38356 KB Output is correct
45 Correct 244 ms 38520 KB Output is correct
46 Correct 248 ms 38376 KB Output is correct
47 Correct 244 ms 38280 KB Output is correct
48 Correct 263 ms 38476 KB Output is correct
49 Correct 187 ms 36896 KB Output is correct
50 Correct 177 ms 36840 KB Output is correct
51 Correct 169 ms 36696 KB Output is correct
52 Correct 170 ms 36756 KB Output is correct
53 Correct 176 ms 37072 KB Output is correct
54 Correct 236 ms 37040 KB Output is correct
55 Correct 182 ms 35320 KB Output is correct
56 Correct 203 ms 36520 KB Output is correct
57 Correct 1329 ms 95960 KB Output is correct
58 Correct 1308 ms 96100 KB Output is correct
59 Correct 1283 ms 93976 KB Output is correct
60 Correct 1292 ms 93472 KB Output is correct
61 Correct 1304 ms 93804 KB Output is correct
62 Correct 1285 ms 93928 KB Output is correct
63 Correct 852 ms 84312 KB Output is correct
64 Correct 854 ms 83776 KB Output is correct
65 Correct 1183 ms 90204 KB Output is correct
66 Correct 1187 ms 90028 KB Output is correct
67 Correct 1231 ms 89120 KB Output is correct
68 Correct 1219 ms 92200 KB Output is correct
69 Correct 1233 ms 92160 KB Output is correct
70 Correct 1263 ms 90964 KB Output is correct
71 Correct 1224 ms 91660 KB Output is correct
72 Correct 1294 ms 91748 KB Output is correct
73 Correct 748 ms 82100 KB Output is correct
74 Correct 761 ms 82144 KB Output is correct
75 Correct 780 ms 81712 KB Output is correct
76 Correct 755 ms 81856 KB Output is correct
77 Correct 753 ms 82268 KB Output is correct
78 Correct 1194 ms 84440 KB Output is correct
79 Correct 828 ms 74008 KB Output is correct
80 Correct 1042 ms 84760 KB Output is correct