Submission #868504

# Submission time Handle Problem Language Result Execution time Memory
868504 2023-10-31T15:04:55 Z hqminhuwu Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
672 ms 90716 KB
#include <bits/stdc++.h>
#define forr(_a,_b,_c) for(_a = (_b); _a <= (_c); ++_a)
#define ford(_a,_b,_c) for(_a = (_b) + 1; _a --> (_c);)
#define forf(_a,_b,_c) for(_a = (_b); _a < (_c); ++_a)
#define st first
#define nd second
#define ll long long
#define ull unsigned long long
#define pii pair <int,int>
#define pll pair <ll,ll>
#define piii pair <int,pii>
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define file "test"


using namespace std;
const int N = 1e6 + 5;
const ll oo = 1e9;
const ll mod = 1e9 + 7;

int bit[N],n;
void update (int u, int val){
    for (; u > 0; u -= u & -u)
        bit[u] = max (bit[u],val);
}

int get (int u){
    int res = 0;
    for (; u <= n; u += u & -u)
        res = max (res,bit[u]);
    return res;
}

stack <int> s;
int q,i,a[N],u,v,h[N],ans[N];
vector <pii> g[N];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> q;
    forr (i,1,n)
        cin >> a[i];
    forr (i,1,q){
        cin >> u >> v;
        cin >> h[i];
        g[v].pb({i,u});
    }
    
    forr (i,1,n){
        while (!s.empty() && a[i] >= a[s.top()])
            s.pop();
        if (!s.empty())
            update(s.top(),a[i] + a[s.top()]);
        s.push(i);
        for (pii w : g[i])
            ans[w.st] = get(w.nd);
    }
    forr (i,1,q)
        cout << (ans[i] <= h[i]) << "\n";
    return 0;
}
/*



*/

# Verdict Execution time Memory Grader output
1 Correct 6 ms 31324 KB Output is correct
2 Correct 6 ms 31420 KB Output is correct
3 Correct 6 ms 31320 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 6 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31436 KB Output is correct
9 Correct 6 ms 31432 KB Output is correct
10 Correct 6 ms 31320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 31324 KB Output is correct
2 Correct 6 ms 31420 KB Output is correct
3 Correct 6 ms 31320 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 6 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31436 KB Output is correct
9 Correct 6 ms 31432 KB Output is correct
10 Correct 6 ms 31320 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 8 ms 31324 KB Output is correct
13 Correct 7 ms 31320 KB Output is correct
14 Correct 8 ms 31324 KB Output is correct
15 Correct 8 ms 31324 KB Output is correct
16 Correct 8 ms 31320 KB Output is correct
17 Correct 8 ms 31324 KB Output is correct
18 Correct 8 ms 31436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 647 ms 84816 KB Output is correct
2 Correct 643 ms 90436 KB Output is correct
3 Correct 672 ms 90296 KB Output is correct
4 Correct 653 ms 90716 KB Output is correct
5 Correct 636 ms 88504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 33284 KB Output is correct
2 Correct 46 ms 32848 KB Output is correct
3 Correct 43 ms 33176 KB Output is correct
4 Correct 46 ms 33364 KB Output is correct
5 Correct 42 ms 33360 KB Output is correct
6 Correct 35 ms 32728 KB Output is correct
7 Correct 34 ms 32592 KB Output is correct
8 Correct 41 ms 33316 KB Output is correct
9 Correct 29 ms 32468 KB Output is correct
10 Correct 40 ms 33136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 31324 KB Output is correct
2 Correct 6 ms 31420 KB Output is correct
3 Correct 6 ms 31320 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 6 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31436 KB Output is correct
9 Correct 6 ms 31432 KB Output is correct
10 Correct 6 ms 31320 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 8 ms 31324 KB Output is correct
13 Correct 7 ms 31320 KB Output is correct
14 Correct 8 ms 31324 KB Output is correct
15 Correct 8 ms 31324 KB Output is correct
16 Correct 8 ms 31320 KB Output is correct
17 Correct 8 ms 31324 KB Output is correct
18 Correct 8 ms 31436 KB Output is correct
19 Correct 102 ms 35396 KB Output is correct
20 Correct 101 ms 35504 KB Output is correct
21 Correct 86 ms 34348 KB Output is correct
22 Correct 86 ms 34320 KB Output is correct
23 Correct 86 ms 34388 KB Output is correct
24 Correct 78 ms 34288 KB Output is correct
25 Correct 80 ms 34128 KB Output is correct
26 Correct 100 ms 34688 KB Output is correct
27 Correct 85 ms 34640 KB Output is correct
28 Correct 85 ms 34896 KB Output is correct
29 Correct 98 ms 35712 KB Output is correct
30 Correct 97 ms 35504 KB Output is correct
31 Correct 91 ms 35384 KB Output is correct
32 Correct 91 ms 35412 KB Output is correct
33 Correct 104 ms 35388 KB Output is correct
34 Correct 73 ms 33840 KB Output is correct
35 Correct 74 ms 33984 KB Output is correct
36 Correct 72 ms 33968 KB Output is correct
37 Correct 74 ms 33964 KB Output is correct
38 Correct 78 ms 33904 KB Output is correct
39 Correct 98 ms 35048 KB Output is correct
40 Correct 74 ms 34828 KB Output is correct
41 Correct 85 ms 35272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 31324 KB Output is correct
2 Correct 6 ms 31420 KB Output is correct
3 Correct 6 ms 31320 KB Output is correct
4 Correct 6 ms 31324 KB Output is correct
5 Correct 6 ms 31324 KB Output is correct
6 Correct 6 ms 31320 KB Output is correct
7 Correct 6 ms 31324 KB Output is correct
8 Correct 6 ms 31436 KB Output is correct
9 Correct 6 ms 31432 KB Output is correct
10 Correct 6 ms 31320 KB Output is correct
11 Correct 7 ms 31324 KB Output is correct
12 Correct 8 ms 31324 KB Output is correct
13 Correct 7 ms 31320 KB Output is correct
14 Correct 8 ms 31324 KB Output is correct
15 Correct 8 ms 31324 KB Output is correct
16 Correct 8 ms 31320 KB Output is correct
17 Correct 8 ms 31324 KB Output is correct
18 Correct 8 ms 31436 KB Output is correct
19 Correct 647 ms 84816 KB Output is correct
20 Correct 643 ms 90436 KB Output is correct
21 Correct 672 ms 90296 KB Output is correct
22 Correct 653 ms 90716 KB Output is correct
23 Correct 636 ms 88504 KB Output is correct
24 Correct 47 ms 33284 KB Output is correct
25 Correct 46 ms 32848 KB Output is correct
26 Correct 43 ms 33176 KB Output is correct
27 Correct 46 ms 33364 KB Output is correct
28 Correct 42 ms 33360 KB Output is correct
29 Correct 35 ms 32728 KB Output is correct
30 Correct 34 ms 32592 KB Output is correct
31 Correct 41 ms 33316 KB Output is correct
32 Correct 29 ms 32468 KB Output is correct
33 Correct 40 ms 33136 KB Output is correct
34 Correct 102 ms 35396 KB Output is correct
35 Correct 101 ms 35504 KB Output is correct
36 Correct 86 ms 34348 KB Output is correct
37 Correct 86 ms 34320 KB Output is correct
38 Correct 86 ms 34388 KB Output is correct
39 Correct 78 ms 34288 KB Output is correct
40 Correct 80 ms 34128 KB Output is correct
41 Correct 100 ms 34688 KB Output is correct
42 Correct 85 ms 34640 KB Output is correct
43 Correct 85 ms 34896 KB Output is correct
44 Correct 98 ms 35712 KB Output is correct
45 Correct 97 ms 35504 KB Output is correct
46 Correct 91 ms 35384 KB Output is correct
47 Correct 91 ms 35412 KB Output is correct
48 Correct 104 ms 35388 KB Output is correct
49 Correct 73 ms 33840 KB Output is correct
50 Correct 74 ms 33984 KB Output is correct
51 Correct 72 ms 33968 KB Output is correct
52 Correct 74 ms 33964 KB Output is correct
53 Correct 78 ms 33904 KB Output is correct
54 Correct 98 ms 35048 KB Output is correct
55 Correct 74 ms 34828 KB Output is correct
56 Correct 85 ms 35272 KB Output is correct
57 Correct 649 ms 89936 KB Output is correct
58 Correct 654 ms 89964 KB Output is correct
59 Correct 590 ms 87072 KB Output is correct
60 Correct 596 ms 83036 KB Output is correct
61 Correct 564 ms 82500 KB Output is correct
62 Correct 638 ms 87412 KB Output is correct
63 Correct 396 ms 80008 KB Output is correct
64 Correct 377 ms 79952 KB Output is correct
65 Correct 543 ms 84820 KB Output is correct
66 Correct 619 ms 84780 KB Output is correct
67 Correct 573 ms 85136 KB Output is correct
68 Correct 621 ms 87980 KB Output is correct
69 Correct 611 ms 87996 KB Output is correct
70 Correct 603 ms 87340 KB Output is correct
71 Correct 620 ms 87472 KB Output is correct
72 Correct 593 ms 87452 KB Output is correct
73 Correct 355 ms 77000 KB Output is correct
74 Correct 364 ms 78376 KB Output is correct
75 Correct 345 ms 73284 KB Output is correct
76 Correct 345 ms 73296 KB Output is correct
77 Correct 360 ms 73056 KB Output is correct
78 Correct 516 ms 77760 KB Output is correct
79 Correct 401 ms 71608 KB Output is correct
80 Correct 550 ms 76292 KB Output is correct