답안 #1032784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032784 2024-07-24T08:35:09 Z pera Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
2586 ms 109384 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int n , m;
vector<int> w(N) , ans(N) , r(N) , t(4 * N);
vector<tuple<int , int , int>> query[N];
void upd(int u , int l , int r , int pos , int x){
   if(l == r){
      t[u] = x;
      return;
   }
   int m = (l + r) / 2;
   if(pos <= m){
      upd(u * 2 , l , m , pos , x);
   }else{
      upd(u * 2 + 1 , m + 1 , r , pos , x);
   }
   t[u] = max(t[u * 2] , t[u * 2 + 1]);
}
int GET(int u , int l , int r , int L , int R){
   if(l > r || r < L || l > R){
      return 0;
   }
   if(L <= l && r <= R){
      return t[u];
   }
   int m = (l + r) / 2;
   return max(GET(u * 2 , l , m , L , R) , GET(u * 2 + 1 , m + 1 , r , L , R));
}
int main(){
   cin >> n >> m;
   for(int i = 1;i <= n;i ++){
      cin >> w[i];
   }
   for(int i = 1;i <= m;i ++){
      int l , r , k;
      cin >> l >> r >> k;
      query[l].push_back({r , k , i});
   }
   for(int i = n;i >= 1;i --){
      r[i] = i + 1;
      while(r[i] <= n && w[i] > w[r[i]]){
         upd(1 , 1 , n , r[i] , w[r[i]] + w[i]);
         r[i] = r[r[i]];
      }
      for(auto [r , k , id] : query[i]){
         ans[id] = GET(1 , 1 , n , i , r) <= k;
      }
   }
   for(int i = 1;i <= m;i ++){
      cout << ans[i] << endl;
   }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 51288 KB Output is correct
2 Correct 19 ms 51292 KB Output is correct
3 Correct 15 ms 51288 KB Output is correct
4 Correct 15 ms 51292 KB Output is correct
5 Correct 15 ms 51288 KB Output is correct
6 Correct 19 ms 51284 KB Output is correct
7 Correct 15 ms 51292 KB Output is correct
8 Correct 16 ms 51292 KB Output is correct
9 Correct 16 ms 51292 KB Output is correct
10 Correct 15 ms 51288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 51288 KB Output is correct
2 Correct 19 ms 51292 KB Output is correct
3 Correct 15 ms 51288 KB Output is correct
4 Correct 15 ms 51292 KB Output is correct
5 Correct 15 ms 51288 KB Output is correct
6 Correct 19 ms 51284 KB Output is correct
7 Correct 15 ms 51292 KB Output is correct
8 Correct 16 ms 51292 KB Output is correct
9 Correct 16 ms 51292 KB Output is correct
10 Correct 15 ms 51288 KB Output is correct
11 Correct 21 ms 51436 KB Output is correct
12 Correct 20 ms 51292 KB Output is correct
13 Correct 25 ms 51292 KB Output is correct
14 Correct 33 ms 51548 KB Output is correct
15 Correct 25 ms 51544 KB Output is correct
16 Correct 22 ms 51292 KB Output is correct
17 Correct 24 ms 51292 KB Output is correct
18 Correct 23 ms 51292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2345 ms 106728 KB Output is correct
2 Correct 2347 ms 107864 KB Output is correct
3 Correct 2379 ms 107760 KB Output is correct
4 Correct 2329 ms 107944 KB Output is correct
5 Correct 2160 ms 107748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 221 ms 55636 KB Output is correct
2 Correct 209 ms 55380 KB Output is correct
3 Correct 193 ms 55376 KB Output is correct
4 Correct 196 ms 55632 KB Output is correct
5 Correct 209 ms 55792 KB Output is correct
6 Correct 195 ms 54868 KB Output is correct
7 Correct 184 ms 54864 KB Output is correct
8 Correct 196 ms 55024 KB Output is correct
9 Correct 165 ms 54280 KB Output is correct
10 Correct 243 ms 54940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 51288 KB Output is correct
2 Correct 19 ms 51292 KB Output is correct
3 Correct 15 ms 51288 KB Output is correct
4 Correct 15 ms 51292 KB Output is correct
5 Correct 15 ms 51288 KB Output is correct
6 Correct 19 ms 51284 KB Output is correct
7 Correct 15 ms 51292 KB Output is correct
8 Correct 16 ms 51292 KB Output is correct
9 Correct 16 ms 51292 KB Output is correct
10 Correct 15 ms 51288 KB Output is correct
11 Correct 21 ms 51436 KB Output is correct
12 Correct 20 ms 51292 KB Output is correct
13 Correct 25 ms 51292 KB Output is correct
14 Correct 33 ms 51548 KB Output is correct
15 Correct 25 ms 51544 KB Output is correct
16 Correct 22 ms 51292 KB Output is correct
17 Correct 24 ms 51292 KB Output is correct
18 Correct 23 ms 51292 KB Output is correct
19 Correct 448 ms 62916 KB Output is correct
20 Correct 456 ms 62824 KB Output is correct
21 Correct 415 ms 62060 KB Output is correct
22 Correct 468 ms 62136 KB Output is correct
23 Correct 417 ms 62036 KB Output is correct
24 Correct 403 ms 61780 KB Output is correct
25 Correct 401 ms 61928 KB Output is correct
26 Correct 411 ms 62292 KB Output is correct
27 Correct 424 ms 62256 KB Output is correct
28 Correct 445 ms 62292 KB Output is correct
29 Correct 460 ms 62772 KB Output is correct
30 Correct 465 ms 62800 KB Output is correct
31 Correct 446 ms 62708 KB Output is correct
32 Correct 434 ms 62644 KB Output is correct
33 Correct 448 ms 62624 KB Output is correct
34 Correct 395 ms 61096 KB Output is correct
35 Correct 392 ms 61176 KB Output is correct
36 Correct 369 ms 60900 KB Output is correct
37 Correct 406 ms 61008 KB Output is correct
38 Correct 385 ms 61160 KB Output is correct
39 Correct 442 ms 60684 KB Output is correct
40 Correct 352 ms 59396 KB Output is correct
41 Correct 427 ms 60304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 51288 KB Output is correct
2 Correct 19 ms 51292 KB Output is correct
3 Correct 15 ms 51288 KB Output is correct
4 Correct 15 ms 51292 KB Output is correct
5 Correct 15 ms 51288 KB Output is correct
6 Correct 19 ms 51284 KB Output is correct
7 Correct 15 ms 51292 KB Output is correct
8 Correct 16 ms 51292 KB Output is correct
9 Correct 16 ms 51292 KB Output is correct
10 Correct 15 ms 51288 KB Output is correct
11 Correct 21 ms 51436 KB Output is correct
12 Correct 20 ms 51292 KB Output is correct
13 Correct 25 ms 51292 KB Output is correct
14 Correct 33 ms 51548 KB Output is correct
15 Correct 25 ms 51544 KB Output is correct
16 Correct 22 ms 51292 KB Output is correct
17 Correct 24 ms 51292 KB Output is correct
18 Correct 23 ms 51292 KB Output is correct
19 Correct 2345 ms 106728 KB Output is correct
20 Correct 2347 ms 107864 KB Output is correct
21 Correct 2379 ms 107760 KB Output is correct
22 Correct 2329 ms 107944 KB Output is correct
23 Correct 2160 ms 107748 KB Output is correct
24 Correct 221 ms 55636 KB Output is correct
25 Correct 209 ms 55380 KB Output is correct
26 Correct 193 ms 55376 KB Output is correct
27 Correct 196 ms 55632 KB Output is correct
28 Correct 209 ms 55792 KB Output is correct
29 Correct 195 ms 54868 KB Output is correct
30 Correct 184 ms 54864 KB Output is correct
31 Correct 196 ms 55024 KB Output is correct
32 Correct 165 ms 54280 KB Output is correct
33 Correct 243 ms 54940 KB Output is correct
34 Correct 448 ms 62916 KB Output is correct
35 Correct 456 ms 62824 KB Output is correct
36 Correct 415 ms 62060 KB Output is correct
37 Correct 468 ms 62136 KB Output is correct
38 Correct 417 ms 62036 KB Output is correct
39 Correct 403 ms 61780 KB Output is correct
40 Correct 401 ms 61928 KB Output is correct
41 Correct 411 ms 62292 KB Output is correct
42 Correct 424 ms 62256 KB Output is correct
43 Correct 445 ms 62292 KB Output is correct
44 Correct 460 ms 62772 KB Output is correct
45 Correct 465 ms 62800 KB Output is correct
46 Correct 446 ms 62708 KB Output is correct
47 Correct 434 ms 62644 KB Output is correct
48 Correct 448 ms 62624 KB Output is correct
49 Correct 395 ms 61096 KB Output is correct
50 Correct 392 ms 61176 KB Output is correct
51 Correct 369 ms 60900 KB Output is correct
52 Correct 406 ms 61008 KB Output is correct
53 Correct 385 ms 61160 KB Output is correct
54 Correct 442 ms 60684 KB Output is correct
55 Correct 352 ms 59396 KB Output is correct
56 Correct 427 ms 60304 KB Output is correct
57 Correct 2352 ms 109292 KB Output is correct
58 Correct 2572 ms 109384 KB Output is correct
59 Correct 2353 ms 107112 KB Output is correct
60 Correct 2450 ms 107296 KB Output is correct
61 Correct 2430 ms 107216 KB Output is correct
62 Correct 2349 ms 107340 KB Output is correct
63 Correct 2133 ms 101608 KB Output is correct
64 Correct 2171 ms 101548 KB Output is correct
65 Correct 2273 ms 107064 KB Output is correct
66 Correct 2095 ms 107116 KB Output is correct
67 Correct 2129 ms 107252 KB Output is correct
68 Correct 2397 ms 109336 KB Output is correct
69 Correct 2586 ms 109160 KB Output is correct
70 Correct 2525 ms 108768 KB Output is correct
71 Correct 2537 ms 108912 KB Output is correct
72 Correct 2507 ms 108728 KB Output is correct
73 Correct 2135 ms 99260 KB Output is correct
74 Correct 2336 ms 99988 KB Output is correct
75 Correct 2148 ms 99040 KB Output is correct
76 Correct 2121 ms 99044 KB Output is correct
77 Correct 2131 ms 99344 KB Output is correct
78 Correct 2302 ms 99220 KB Output is correct
79 Correct 2066 ms 92432 KB Output is correct
80 Correct 2277 ms 96116 KB Output is correct