Submission #151706

# Submission time Handle Problem Language Result Execution time Memory
151706 2019-09-04T08:32:48 Z leatherman Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
64 / 100
3000 ms 129784 KB
#include <bits/stdc++.h>

#define fi first
#define se second

using namespace std;
const int N = 4e6 + 200;

pair<int, int> v[N],b[N];
vector<int> q[N];
int t[4 * N],a[N],n,Q,limit,l,r,x,step,pos,val;
bool ans[N];
void upd(int v,int tl,int tr)
{
    if(tl == tr)
    {
        t[v] = val + a[tl];
        return;
    }
    int tm = (tl + tr) >> 1;
    if(pos <= tm) upd(v << 1, tl, tm);
    else upd(v << 1 | 1, tm + 1, tr);
    t[v] = max(t[v << 1], t[v << 1 | 1]);
}
int get(int v,int tl,int tr)
{
    if(tr < l || tl > r) return 0;
    if(tl >= l && tr <= r) return t[v];
    int tm = (tl + tr) >> 1;
    return max(get(v << 1, tl, tm), get(v << 1 | 1, tm + 1, tr));
}
void make(int l,int r)
{
    int x,Pos;
    for(int i = r; i >= l; i--)
    {
        x = a[i];
        while(step > 0 && x > v[step].fi)
        {
            Pos = v[step].se;
            pos = Pos;
            val = x;
            upd(1, 1, n);
            step--;
        }
        v[++step] = {x, i};
    }
}
int main()
{
    ios_base::sync_with_stdio();cin.tie(0);
    cin>>n>>Q;
    for(int i = 1; i <= n; i++) cin>>a[i];
    limit = n;
    for(int i = 1; i <= Q; i++)
    {
        cin>>l>>r>>x;
        b[i] = {r, x};
        q[l].push_back(i);
    }
    for(int j = n; j > 0; j--) if(!q[j].empty())
        for(auto i : q[j])
        {
            l = j;
            r = b[i].fi;
            if(limit >= l)
            {
                make(l, limit);
                limit = l - 1;
            }
            x = get(1, 1, n);
            ans[i] = (x <= b[i].se);
        }
    for(int i = 1; i <= Q; i++) cout<<ans[i]<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 87 ms 94328 KB Output is correct
2 Correct 115 ms 94328 KB Output is correct
3 Correct 90 ms 94292 KB Output is correct
4 Correct 98 ms 94392 KB Output is correct
5 Correct 89 ms 94328 KB Output is correct
6 Correct 90 ms 94296 KB Output is correct
7 Correct 90 ms 94328 KB Output is correct
8 Correct 89 ms 94328 KB Output is correct
9 Correct 89 ms 94328 KB Output is correct
10 Correct 89 ms 94328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 94328 KB Output is correct
2 Correct 115 ms 94328 KB Output is correct
3 Correct 90 ms 94292 KB Output is correct
4 Correct 98 ms 94392 KB Output is correct
5 Correct 89 ms 94328 KB Output is correct
6 Correct 90 ms 94296 KB Output is correct
7 Correct 90 ms 94328 KB Output is correct
8 Correct 89 ms 94328 KB Output is correct
9 Correct 89 ms 94328 KB Output is correct
10 Correct 89 ms 94328 KB Output is correct
11 Correct 95 ms 94500 KB Output is correct
12 Correct 99 ms 94608 KB Output is correct
13 Correct 101 ms 94732 KB Output is correct
14 Correct 105 ms 94712 KB Output is correct
15 Correct 106 ms 94712 KB Output is correct
16 Correct 101 ms 94628 KB Output is correct
17 Correct 98 ms 94496 KB Output is correct
18 Correct 99 ms 94584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3034 ms 129784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 346 ms 98936 KB Output is correct
2 Correct 330 ms 98028 KB Output is correct
3 Correct 329 ms 98388 KB Output is correct
4 Correct 333 ms 98680 KB Output is correct
5 Correct 330 ms 98688 KB Output is correct
6 Correct 288 ms 97272 KB Output is correct
7 Correct 289 ms 97364 KB Output is correct
8 Correct 303 ms 98276 KB Output is correct
9 Correct 224 ms 96116 KB Output is correct
10 Correct 300 ms 98168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 94328 KB Output is correct
2 Correct 115 ms 94328 KB Output is correct
3 Correct 90 ms 94292 KB Output is correct
4 Correct 98 ms 94392 KB Output is correct
5 Correct 89 ms 94328 KB Output is correct
6 Correct 90 ms 94296 KB Output is correct
7 Correct 90 ms 94328 KB Output is correct
8 Correct 89 ms 94328 KB Output is correct
9 Correct 89 ms 94328 KB Output is correct
10 Correct 89 ms 94328 KB Output is correct
11 Correct 95 ms 94500 KB Output is correct
12 Correct 99 ms 94608 KB Output is correct
13 Correct 101 ms 94732 KB Output is correct
14 Correct 105 ms 94712 KB Output is correct
15 Correct 106 ms 94712 KB Output is correct
16 Correct 101 ms 94628 KB Output is correct
17 Correct 98 ms 94496 KB Output is correct
18 Correct 99 ms 94584 KB Output is correct
19 Correct 799 ms 103464 KB Output is correct
20 Correct 786 ms 103540 KB Output is correct
21 Correct 720 ms 101240 KB Output is correct
22 Correct 727 ms 101300 KB Output is correct
23 Correct 724 ms 101128 KB Output is correct
24 Correct 695 ms 100628 KB Output is correct
25 Correct 697 ms 100464 KB Output is correct
26 Correct 721 ms 101236 KB Output is correct
27 Correct 724 ms 101364 KB Output is correct
28 Correct 731 ms 101880 KB Output is correct
29 Correct 744 ms 102876 KB Output is correct
30 Correct 748 ms 102904 KB Output is correct
31 Correct 745 ms 102836 KB Output is correct
32 Correct 756 ms 102808 KB Output is correct
33 Correct 790 ms 102936 KB Output is correct
34 Correct 666 ms 100104 KB Output is correct
35 Correct 653 ms 100224 KB Output is correct
36 Correct 666 ms 100216 KB Output is correct
37 Correct 641 ms 100012 KB Output is correct
38 Correct 654 ms 100144 KB Output is correct
39 Correct 635 ms 101652 KB Output is correct
40 Correct 543 ms 100540 KB Output is correct
41 Correct 629 ms 101976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 94328 KB Output is correct
2 Correct 115 ms 94328 KB Output is correct
3 Correct 90 ms 94292 KB Output is correct
4 Correct 98 ms 94392 KB Output is correct
5 Correct 89 ms 94328 KB Output is correct
6 Correct 90 ms 94296 KB Output is correct
7 Correct 90 ms 94328 KB Output is correct
8 Correct 89 ms 94328 KB Output is correct
9 Correct 89 ms 94328 KB Output is correct
10 Correct 89 ms 94328 KB Output is correct
11 Correct 95 ms 94500 KB Output is correct
12 Correct 99 ms 94608 KB Output is correct
13 Correct 101 ms 94732 KB Output is correct
14 Correct 105 ms 94712 KB Output is correct
15 Correct 106 ms 94712 KB Output is correct
16 Correct 101 ms 94628 KB Output is correct
17 Correct 98 ms 94496 KB Output is correct
18 Correct 99 ms 94584 KB Output is correct
19 Execution timed out 3034 ms 129784 KB Time limit exceeded
20 Halted 0 ms 0 KB -