Submission #572072

# Submission time Handle Problem Language Result Execution time Memory
572072 2022-06-03T13:36:14 Z Hanksburger Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
64 / 100
143 ms 20312 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > v[200005];
vector<pair<int, int> > w;
int a[200005], b[200005];
bool c[200005];
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++)
    {
//        cout << "i=" << i << '\n';
        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];
//            cout << "update " << w[w.size()-1].second << ' ' << x << '\n';
            for (int i=w[w.size()-1].second; i; i-=(i&-i))
                b[i]=max(b[i], x);
        }
        w.push_back({a[i], i});
//        cout << "w: ";
//        for (pair<int, int> x:w)
//            cout << x.first << ' ';
//        cout << '\n';
        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:39: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]
   39 |         for (int j=0; j<v[i].size(); j++)
      |                       ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5036 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 3 ms 5044 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5036 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 3 ms 5044 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 5076 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 5 ms 5168 KB Output is correct
14 Correct 6 ms 5300 KB Output is correct
15 Correct 7 ms 5332 KB Output is correct
16 Correct 6 ms 5204 KB Output is correct
17 Correct 5 ms 5172 KB Output is correct
18 Correct 5 ms 5172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 20312 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 10188 KB Output is correct
2 Correct 50 ms 9932 KB Output is correct
3 Correct 60 ms 9716 KB Output is correct
4 Correct 48 ms 9760 KB Output is correct
5 Correct 50 ms 9692 KB Output is correct
6 Correct 42 ms 9228 KB Output is correct
7 Correct 42 ms 9200 KB Output is correct
8 Correct 51 ms 9392 KB Output is correct
9 Correct 34 ms 8080 KB Output is correct
10 Correct 48 ms 9380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5036 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 3 ms 5044 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 5076 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 5 ms 5168 KB Output is correct
14 Correct 6 ms 5300 KB Output is correct
15 Correct 7 ms 5332 KB Output is correct
16 Correct 6 ms 5204 KB Output is correct
17 Correct 5 ms 5172 KB Output is correct
18 Correct 5 ms 5172 KB Output is correct
19 Correct 138 ms 16224 KB Output is correct
20 Correct 143 ms 16172 KB Output is correct
21 Correct 117 ms 15488 KB Output is correct
22 Correct 117 ms 15348 KB Output is correct
23 Correct 110 ms 15356 KB Output is correct
24 Correct 110 ms 14520 KB Output is correct
25 Correct 103 ms 14560 KB Output is correct
26 Correct 121 ms 14756 KB Output is correct
27 Correct 120 ms 14940 KB Output is correct
28 Correct 122 ms 14756 KB Output is correct
29 Correct 121 ms 15048 KB Output is correct
30 Correct 130 ms 15020 KB Output is correct
31 Correct 124 ms 15020 KB Output is correct
32 Correct 122 ms 15088 KB Output is correct
33 Correct 136 ms 15144 KB Output is correct
34 Correct 101 ms 14264 KB Output is correct
35 Correct 104 ms 14240 KB Output is correct
36 Correct 94 ms 14200 KB Output is correct
37 Correct 104 ms 14252 KB Output is correct
38 Correct 103 ms 14160 KB Output is correct
39 Correct 114 ms 14988 KB Output is correct
40 Correct 102 ms 14228 KB Output is correct
41 Correct 117 ms 14844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5036 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5048 KB Output is correct
8 Correct 3 ms 5044 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 3 ms 4948 KB Output is correct
11 Correct 4 ms 5076 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 5 ms 5168 KB Output is correct
14 Correct 6 ms 5300 KB Output is correct
15 Correct 7 ms 5332 KB Output is correct
16 Correct 6 ms 5204 KB Output is correct
17 Correct 5 ms 5172 KB Output is correct
18 Correct 5 ms 5172 KB Output is correct
19 Runtime error 100 ms 20312 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -