Submission #445447

# Submission time Handle Problem Language Result Execution time Memory
445447 2021-07-18T03:45:51 Z SirCovidThe19th Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
2490 ms 92408 KB
#include <bits/stdc++.h>
using namespace std; 

const int mx = 1e6+5;

int n, m, A[mx], bit[mx], ans[mx]; vector<array<int, 3>> R[mx];

void upd(int i, int val){
    for (; i > 0; i -= i&(-i)) bit[i] = max(bit[i], val);
}
int query(int i){
    int ret = 0;
    for (; i <= n; i += i&(-i)) ret = max(ret, bit[i]);
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); 
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> A[i];
    for (int i = 1; i <= m; i++){
        int l, r, k; cin >> l >> r >> k;
        R[r].push_back({l, k, i});
    }stack<int> stk;
    for (int i = 1; i <= n; i++){
        while (!stk.empty() and A[stk.top()] <= A[i]) stk.pop();
        if (!stk.empty()) upd(stk.top(), A[stk.top()]+A[i]);
        for (auto x : R[i]) ans[x[2]] = (query(x[0]) <= x[1]);
        stk.push(i);
    }for (int i = 1; i <= m; i++) cout<<ans[i]<<endl;
}

# Verdict Execution time Memory Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 15 ms 23748 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 14 ms 23776 KB Output is correct
6 Correct 15 ms 23720 KB Output is correct
7 Correct 16 ms 23776 KB Output is correct
8 Correct 15 ms 23844 KB Output is correct
9 Correct 15 ms 23760 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 15 ms 23748 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 14 ms 23776 KB Output is correct
6 Correct 15 ms 23720 KB Output is correct
7 Correct 16 ms 23776 KB Output is correct
8 Correct 15 ms 23844 KB Output is correct
9 Correct 15 ms 23760 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
11 Correct 20 ms 23884 KB Output is correct
12 Correct 20 ms 23944 KB Output is correct
13 Correct 20 ms 23888 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23988 KB Output is correct
16 Correct 24 ms 23980 KB Output is correct
17 Correct 25 ms 23884 KB Output is correct
18 Correct 30 ms 23976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2406 ms 59168 KB Output is correct
2 Correct 2483 ms 92008 KB Output is correct
3 Correct 2490 ms 92064 KB Output is correct
4 Correct 2461 ms 92320 KB Output is correct
5 Correct 2360 ms 88172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 239 ms 27200 KB Output is correct
2 Correct 218 ms 26968 KB Output is correct
3 Correct 223 ms 26692 KB Output is correct
4 Correct 219 ms 26872 KB Output is correct
5 Correct 217 ms 26896 KB Output is correct
6 Correct 209 ms 26468 KB Output is correct
7 Correct 210 ms 26404 KB Output is correct
8 Correct 217 ms 26728 KB Output is correct
9 Correct 198 ms 25852 KB Output is correct
10 Correct 223 ms 26780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 15 ms 23748 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 14 ms 23776 KB Output is correct
6 Correct 15 ms 23720 KB Output is correct
7 Correct 16 ms 23776 KB Output is correct
8 Correct 15 ms 23844 KB Output is correct
9 Correct 15 ms 23760 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
11 Correct 20 ms 23884 KB Output is correct
12 Correct 20 ms 23944 KB Output is correct
13 Correct 20 ms 23888 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23988 KB Output is correct
16 Correct 24 ms 23980 KB Output is correct
17 Correct 25 ms 23884 KB Output is correct
18 Correct 30 ms 23976 KB Output is correct
19 Correct 470 ms 30888 KB Output is correct
20 Correct 471 ms 30916 KB Output is correct
21 Correct 449 ms 30240 KB Output is correct
22 Correct 445 ms 30276 KB Output is correct
23 Correct 447 ms 30356 KB Output is correct
24 Correct 431 ms 29472 KB Output is correct
25 Correct 442 ms 29476 KB Output is correct
26 Correct 451 ms 29696 KB Output is correct
27 Correct 440 ms 29508 KB Output is correct
28 Correct 452 ms 29892 KB Output is correct
29 Correct 449 ms 30020 KB Output is correct
30 Correct 465 ms 30012 KB Output is correct
31 Correct 462 ms 30096 KB Output is correct
32 Correct 450 ms 29932 KB Output is correct
33 Correct 459 ms 30028 KB Output is correct
34 Correct 432 ms 29080 KB Output is correct
35 Correct 435 ms 29076 KB Output is correct
36 Correct 430 ms 29132 KB Output is correct
37 Correct 421 ms 29252 KB Output is correct
38 Correct 428 ms 29120 KB Output is correct
39 Correct 452 ms 29816 KB Output is correct
40 Correct 436 ms 29044 KB Output is correct
41 Correct 436 ms 29684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 23756 KB Output is correct
2 Correct 14 ms 23808 KB Output is correct
3 Correct 15 ms 23748 KB Output is correct
4 Correct 14 ms 23756 KB Output is correct
5 Correct 14 ms 23776 KB Output is correct
6 Correct 15 ms 23720 KB Output is correct
7 Correct 16 ms 23776 KB Output is correct
8 Correct 15 ms 23844 KB Output is correct
9 Correct 15 ms 23760 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
11 Correct 20 ms 23884 KB Output is correct
12 Correct 20 ms 23944 KB Output is correct
13 Correct 20 ms 23888 KB Output is correct
14 Correct 26 ms 23936 KB Output is correct
15 Correct 24 ms 23988 KB Output is correct
16 Correct 24 ms 23980 KB Output is correct
17 Correct 25 ms 23884 KB Output is correct
18 Correct 30 ms 23976 KB Output is correct
19 Correct 2406 ms 59168 KB Output is correct
20 Correct 2483 ms 92008 KB Output is correct
21 Correct 2490 ms 92064 KB Output is correct
22 Correct 2461 ms 92320 KB Output is correct
23 Correct 2360 ms 88172 KB Output is correct
24 Correct 239 ms 27200 KB Output is correct
25 Correct 218 ms 26968 KB Output is correct
26 Correct 223 ms 26692 KB Output is correct
27 Correct 219 ms 26872 KB Output is correct
28 Correct 217 ms 26896 KB Output is correct
29 Correct 209 ms 26468 KB Output is correct
30 Correct 210 ms 26404 KB Output is correct
31 Correct 217 ms 26728 KB Output is correct
32 Correct 198 ms 25852 KB Output is correct
33 Correct 223 ms 26780 KB Output is correct
34 Correct 470 ms 30888 KB Output is correct
35 Correct 471 ms 30916 KB Output is correct
36 Correct 449 ms 30240 KB Output is correct
37 Correct 445 ms 30276 KB Output is correct
38 Correct 447 ms 30356 KB Output is correct
39 Correct 431 ms 29472 KB Output is correct
40 Correct 442 ms 29476 KB Output is correct
41 Correct 451 ms 29696 KB Output is correct
42 Correct 440 ms 29508 KB Output is correct
43 Correct 452 ms 29892 KB Output is correct
44 Correct 449 ms 30020 KB Output is correct
45 Correct 465 ms 30012 KB Output is correct
46 Correct 462 ms 30096 KB Output is correct
47 Correct 450 ms 29932 KB Output is correct
48 Correct 459 ms 30028 KB Output is correct
49 Correct 432 ms 29080 KB Output is correct
50 Correct 435 ms 29076 KB Output is correct
51 Correct 430 ms 29132 KB Output is correct
52 Correct 421 ms 29252 KB Output is correct
53 Correct 428 ms 29120 KB Output is correct
54 Correct 452 ms 29816 KB Output is correct
55 Correct 436 ms 29044 KB Output is correct
56 Correct 436 ms 29684 KB Output is correct
57 Correct 2467 ms 92292 KB Output is correct
58 Correct 2482 ms 92408 KB Output is correct
59 Correct 2429 ms 90792 KB Output is correct
60 Correct 2403 ms 90772 KB Output is correct
61 Correct 2400 ms 90720 KB Output is correct
62 Correct 2411 ms 90764 KB Output is correct
63 Correct 2140 ms 83684 KB Output is correct
64 Correct 2148 ms 83568 KB Output is correct
65 Correct 2347 ms 86712 KB Output is correct
66 Correct 2362 ms 86608 KB Output is correct
67 Correct 2382 ms 86788 KB Output is correct
68 Correct 2395 ms 88668 KB Output is correct
69 Correct 2429 ms 88492 KB Output is correct
70 Correct 2370 ms 88064 KB Output is correct
71 Correct 2404 ms 88296 KB Output is correct
72 Correct 2400 ms 88032 KB Output is correct
73 Correct 2082 ms 79588 KB Output is correct
74 Correct 2116 ms 80576 KB Output is correct
75 Correct 2100 ms 79584 KB Output is correct
76 Correct 2101 ms 79720 KB Output is correct
77 Correct 2108 ms 79340 KB Output is correct
78 Correct 2290 ms 81872 KB Output is correct
79 Correct 2139 ms 71492 KB Output is correct
80 Correct 2303 ms 77752 KB Output is correct