Submission #572073

# Submission time Handle Problem Language Result Execution time Memory
572073 2022-06-03T13:37:28 Z Hanksburger Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
865 ms 76616 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > v[1000005];
int a[1000005], b[1000005];
vector<pair<int, int> > w;
bool c[1000005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i=1; i<=n; i++)
        cin >> a[i];
    for (int i=1; i<=q; i++)
    {
        int l, r, x;
        cin >> l >> r >> x;
        v[r].push_back({{l, x}, i});
    }
    for (int i=1; i<=n; i++)
    {
        while (w.size() && w[w.size()-1].first<=a[i])
            w.pop_back();
        if (w.size())
        {
            int x=w[w.size()-1].first+a[i];
            for (int i=w[w.size()-1].second; i; i-=(i&-i))
                b[i]=max(b[i], x);
        }
        w.push_back({a[i], i});
        for (int j=0; j<v[i].size(); j++)
        {
            int mx=0;
            for (int k=v[i][j].first.first; k<=n; k+=(k&-k))
                mx=max(mx, b[k]);
            c[v[i][j].second]=(mx<=v[i][j].first.second);
        }
    }
    for (int i=1; i<=q; i++)
        cout << c[i] << '\n';
    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j=0; j<v[i].size(); j++)
      |                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 13 ms 23740 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
4 Correct 13 ms 23760 KB Output is correct
5 Correct 15 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23804 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23744 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 13 ms 23740 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
4 Correct 13 ms 23760 KB Output is correct
5 Correct 15 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23804 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23744 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 12 ms 23888 KB Output is correct
12 Correct 13 ms 23892 KB Output is correct
13 Correct 14 ms 23852 KB Output is correct
14 Correct 15 ms 23904 KB Output is correct
15 Correct 19 ms 23940 KB Output is correct
16 Correct 16 ms 23892 KB Output is correct
17 Correct 14 ms 23892 KB Output is correct
18 Correct 15 ms 23892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 806 ms 60368 KB Output is correct
2 Correct 797 ms 57208 KB Output is correct
3 Correct 825 ms 57188 KB Output is correct
4 Correct 865 ms 76616 KB Output is correct
5 Correct 772 ms 57692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 26940 KB Output is correct
2 Correct 60 ms 26700 KB Output is correct
3 Correct 67 ms 26444 KB Output is correct
4 Correct 57 ms 26572 KB Output is correct
5 Correct 60 ms 26556 KB Output is correct
6 Correct 52 ms 26184 KB Output is correct
7 Correct 58 ms 26204 KB Output is correct
8 Correct 58 ms 26392 KB Output is correct
9 Correct 42 ms 25516 KB Output is correct
10 Correct 60 ms 26392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 13 ms 23740 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
4 Correct 13 ms 23760 KB Output is correct
5 Correct 15 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23804 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23744 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 12 ms 23888 KB Output is correct
12 Correct 13 ms 23892 KB Output is correct
13 Correct 14 ms 23852 KB Output is correct
14 Correct 15 ms 23904 KB Output is correct
15 Correct 19 ms 23940 KB Output is correct
16 Correct 16 ms 23892 KB Output is correct
17 Correct 14 ms 23892 KB Output is correct
18 Correct 15 ms 23892 KB Output is correct
19 Correct 148 ms 30248 KB Output is correct
20 Correct 152 ms 30312 KB Output is correct
21 Correct 115 ms 29600 KB Output is correct
22 Correct 133 ms 29644 KB Output is correct
23 Correct 120 ms 29684 KB Output is correct
24 Correct 114 ms 28820 KB Output is correct
25 Correct 116 ms 28880 KB Output is correct
26 Correct 128 ms 29036 KB Output is correct
27 Correct 118 ms 28956 KB Output is correct
28 Correct 142 ms 29092 KB Output is correct
29 Correct 135 ms 29360 KB Output is correct
30 Correct 126 ms 29324 KB Output is correct
31 Correct 129 ms 29296 KB Output is correct
32 Correct 148 ms 29348 KB Output is correct
33 Correct 147 ms 29340 KB Output is correct
34 Correct 106 ms 28500 KB Output is correct
35 Correct 109 ms 28588 KB Output is correct
36 Correct 114 ms 28504 KB Output is correct
37 Correct 105 ms 28504 KB Output is correct
38 Correct 106 ms 28500 KB Output is correct
39 Correct 121 ms 29304 KB Output is correct
40 Correct 119 ms 28356 KB Output is correct
41 Correct 133 ms 29164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 13 ms 23740 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
4 Correct 13 ms 23760 KB Output is correct
5 Correct 15 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23804 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23744 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 12 ms 23888 KB Output is correct
12 Correct 13 ms 23892 KB Output is correct
13 Correct 14 ms 23852 KB Output is correct
14 Correct 15 ms 23904 KB Output is correct
15 Correct 19 ms 23940 KB Output is correct
16 Correct 16 ms 23892 KB Output is correct
17 Correct 14 ms 23892 KB Output is correct
18 Correct 15 ms 23892 KB Output is correct
19 Correct 806 ms 60368 KB Output is correct
20 Correct 797 ms 57208 KB Output is correct
21 Correct 825 ms 57188 KB Output is correct
22 Correct 865 ms 76616 KB Output is correct
23 Correct 772 ms 57692 KB Output is correct
24 Correct 70 ms 26940 KB Output is correct
25 Correct 60 ms 26700 KB Output is correct
26 Correct 67 ms 26444 KB Output is correct
27 Correct 57 ms 26572 KB Output is correct
28 Correct 60 ms 26556 KB Output is correct
29 Correct 52 ms 26184 KB Output is correct
30 Correct 58 ms 26204 KB Output is correct
31 Correct 58 ms 26392 KB Output is correct
32 Correct 42 ms 25516 KB Output is correct
33 Correct 60 ms 26392 KB Output is correct
34 Correct 148 ms 30248 KB Output is correct
35 Correct 152 ms 30312 KB Output is correct
36 Correct 115 ms 29600 KB Output is correct
37 Correct 133 ms 29644 KB Output is correct
38 Correct 120 ms 29684 KB Output is correct
39 Correct 114 ms 28820 KB Output is correct
40 Correct 116 ms 28880 KB Output is correct
41 Correct 128 ms 29036 KB Output is correct
42 Correct 118 ms 28956 KB Output is correct
43 Correct 142 ms 29092 KB Output is correct
44 Correct 135 ms 29360 KB Output is correct
45 Correct 126 ms 29324 KB Output is correct
46 Correct 129 ms 29296 KB Output is correct
47 Correct 148 ms 29348 KB Output is correct
48 Correct 147 ms 29340 KB Output is correct
49 Correct 106 ms 28500 KB Output is correct
50 Correct 109 ms 28588 KB Output is correct
51 Correct 114 ms 28504 KB Output is correct
52 Correct 105 ms 28504 KB Output is correct
53 Correct 106 ms 28500 KB Output is correct
54 Correct 121 ms 29304 KB Output is correct
55 Correct 119 ms 28356 KB Output is correct
56 Correct 133 ms 29164 KB Output is correct
57 Correct 859 ms 73008 KB Output is correct
58 Correct 781 ms 61464 KB Output is correct
59 Correct 807 ms 59784 KB Output is correct
60 Correct 762 ms 60192 KB Output is correct
61 Correct 801 ms 59616 KB Output is correct
62 Correct 768 ms 59848 KB Output is correct
63 Correct 523 ms 54468 KB Output is correct
64 Correct 516 ms 54564 KB Output is correct
65 Correct 735 ms 55708 KB Output is correct
66 Correct 746 ms 71312 KB Output is correct
67 Correct 754 ms 71592 KB Output is correct
68 Correct 810 ms 57124 KB Output is correct
69 Correct 781 ms 57048 KB Output is correct
70 Correct 780 ms 73248 KB Output is correct
71 Correct 799 ms 73080 KB Output is correct
72 Correct 801 ms 56712 KB Output is correct
73 Correct 471 ms 51468 KB Output is correct
74 Correct 510 ms 51468 KB Output is correct
75 Correct 486 ms 51384 KB Output is correct
76 Correct 506 ms 51628 KB Output is correct
77 Correct 491 ms 51320 KB Output is correct
78 Correct 704 ms 56400 KB Output is correct
79 Correct 561 ms 50716 KB Output is correct
80 Correct 652 ms 54532 KB Output is correct