답안 #868544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
868544 2023-10-31T17:57:40 Z alexdd Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
645 ms 95056 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[1000005];
int tole[1000005];
int rez[1000005];
deque<int> dq;
vector<pair<pair<int,int>,int>> qrys[1000005];
int aib[10000005];
int qry(int poz)
{
    int aux=0;
    for(int i=poz;i<=n;i+=(i&(-i)))
        aux=max(aux,aib[i]);
    return aux;
}
void upd(int poz, int newv)
{
    for(int i=poz;i>0;i-=(i&(-i)))
        aib[i]=max(aib[i],newv);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        while(!dq.empty() && a[dq.back()]<=a[i])
            dq.pop_back();
        if(dq.empty())
            tole[i]=0;
        else
            tole[i]=dq.back();
        dq.push_back(i);
    }
    int ql,qr,k;
    for(int i=1;i<=m;i++)
    {
        cin>>ql>>qr>>k;
        qrys[qr].push_back({{ql,k},i});
    }
    for(int i=1;i<=n;i++)
    {
        if(tole[i]>0) upd(tole[i],a[i]+a[tole[i]]);
        for(auto x:qrys[i])
        {
            int le=x.first.first;
            int mxm=qry(le);
            /**int mxm=0;
            for(int j=1;j<=i;j++)
                if(tole[j]>=le)
                    mxm=max(mxm, a[j]+a[tole[j]]);*/
            if(mxm<=x.first.second)
                rez[x.second]=1;
            else
                rez[x.second]=0;
        }
    }
    for(int i=1;i<=m;i++)
        cout<<rez[i]<<"\n";
    return 0;
}
/**
tole[i] = prima pozitie din stanga lui i > a[i]
max(a[j] + a[tole[j]]) pt j = le..ri && tole[j] >= le

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31064 KB Output is correct
2 Correct 7 ms 31068 KB Output is correct
3 Correct 6 ms 31068 KB Output is correct
4 Correct 6 ms 31252 KB Output is correct
5 Correct 6 ms 31224 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 6 ms 31068 KB Output is correct
8 Correct 6 ms 31068 KB Output is correct
9 Correct 6 ms 31068 KB Output is correct
10 Correct 6 ms 31176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31064 KB Output is correct
2 Correct 7 ms 31068 KB Output is correct
3 Correct 6 ms 31068 KB Output is correct
4 Correct 6 ms 31252 KB Output is correct
5 Correct 6 ms 31224 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 6 ms 31068 KB Output is correct
8 Correct 6 ms 31068 KB Output is correct
9 Correct 6 ms 31068 KB Output is correct
10 Correct 6 ms 31176 KB Output is correct
11 Correct 7 ms 31064 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31240 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 31192 KB Output is correct
17 Correct 9 ms 31312 KB Output is correct
18 Correct 8 ms 31324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 635 ms 65404 KB Output is correct
2 Correct 638 ms 65180 KB Output is correct
3 Correct 645 ms 65380 KB Output is correct
4 Correct 637 ms 65556 KB Output is correct
5 Correct 590 ms 61436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 33872 KB Output is correct
2 Correct 42 ms 33708 KB Output is correct
3 Correct 43 ms 35404 KB Output is correct
4 Correct 44 ms 35408 KB Output is correct
5 Correct 43 ms 35436 KB Output is correct
6 Correct 36 ms 34956 KB Output is correct
7 Correct 36 ms 34860 KB Output is correct
8 Correct 42 ms 35088 KB Output is correct
9 Correct 29 ms 34068 KB Output is correct
10 Correct 42 ms 34984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31064 KB Output is correct
2 Correct 7 ms 31068 KB Output is correct
3 Correct 6 ms 31068 KB Output is correct
4 Correct 6 ms 31252 KB Output is correct
5 Correct 6 ms 31224 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 6 ms 31068 KB Output is correct
8 Correct 6 ms 31068 KB Output is correct
9 Correct 6 ms 31068 KB Output is correct
10 Correct 6 ms 31176 KB Output is correct
11 Correct 7 ms 31064 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31240 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 31192 KB Output is correct
17 Correct 9 ms 31312 KB Output is correct
18 Correct 8 ms 31324 KB Output is correct
19 Correct 99 ms 36432 KB Output is correct
20 Correct 108 ms 42556 KB Output is correct
21 Correct 92 ms 42032 KB Output is correct
22 Correct 91 ms 41832 KB Output is correct
23 Correct 95 ms 41840 KB Output is correct
24 Correct 84 ms 40892 KB Output is correct
25 Correct 82 ms 40924 KB Output is correct
26 Correct 87 ms 41376 KB Output is correct
27 Correct 89 ms 41296 KB Output is correct
28 Correct 89 ms 41552 KB Output is correct
29 Correct 97 ms 41812 KB Output is correct
30 Correct 95 ms 41808 KB Output is correct
31 Correct 93 ms 41708 KB Output is correct
32 Correct 94 ms 41856 KB Output is correct
33 Correct 105 ms 41708 KB Output is correct
34 Correct 78 ms 40532 KB Output is correct
35 Correct 77 ms 40664 KB Output is correct
36 Correct 79 ms 40816 KB Output is correct
37 Correct 76 ms 40588 KB Output is correct
38 Correct 79 ms 40656 KB Output is correct
39 Correct 90 ms 40460 KB Output is correct
40 Correct 90 ms 39208 KB Output is correct
41 Correct 84 ms 40444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31064 KB Output is correct
2 Correct 7 ms 31068 KB Output is correct
3 Correct 6 ms 31068 KB Output is correct
4 Correct 6 ms 31252 KB Output is correct
5 Correct 6 ms 31224 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 6 ms 31068 KB Output is correct
8 Correct 6 ms 31068 KB Output is correct
9 Correct 6 ms 31068 KB Output is correct
10 Correct 6 ms 31176 KB Output is correct
11 Correct 7 ms 31064 KB Output is correct
12 Correct 7 ms 31324 KB Output is correct
13 Correct 7 ms 31240 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 31192 KB Output is correct
17 Correct 9 ms 31312 KB Output is correct
18 Correct 8 ms 31324 KB Output is correct
19 Correct 635 ms 65404 KB Output is correct
20 Correct 638 ms 65180 KB Output is correct
21 Correct 645 ms 65380 KB Output is correct
22 Correct 637 ms 65556 KB Output is correct
23 Correct 590 ms 61436 KB Output is correct
24 Correct 46 ms 33872 KB Output is correct
25 Correct 42 ms 33708 KB Output is correct
26 Correct 43 ms 35404 KB Output is correct
27 Correct 44 ms 35408 KB Output is correct
28 Correct 43 ms 35436 KB Output is correct
29 Correct 36 ms 34956 KB Output is correct
30 Correct 36 ms 34860 KB Output is correct
31 Correct 42 ms 35088 KB Output is correct
32 Correct 29 ms 34068 KB Output is correct
33 Correct 42 ms 34984 KB Output is correct
34 Correct 99 ms 36432 KB Output is correct
35 Correct 108 ms 42556 KB Output is correct
36 Correct 92 ms 42032 KB Output is correct
37 Correct 91 ms 41832 KB Output is correct
38 Correct 95 ms 41840 KB Output is correct
39 Correct 84 ms 40892 KB Output is correct
40 Correct 82 ms 40924 KB Output is correct
41 Correct 87 ms 41376 KB Output is correct
42 Correct 89 ms 41296 KB Output is correct
43 Correct 89 ms 41552 KB Output is correct
44 Correct 97 ms 41812 KB Output is correct
45 Correct 95 ms 41808 KB Output is correct
46 Correct 93 ms 41708 KB Output is correct
47 Correct 94 ms 41856 KB Output is correct
48 Correct 105 ms 41708 KB Output is correct
49 Correct 78 ms 40532 KB Output is correct
50 Correct 77 ms 40664 KB Output is correct
51 Correct 79 ms 40816 KB Output is correct
52 Correct 76 ms 40588 KB Output is correct
53 Correct 79 ms 40656 KB Output is correct
54 Correct 90 ms 40460 KB Output is correct
55 Correct 90 ms 39208 KB Output is correct
56 Correct 84 ms 40444 KB Output is correct
57 Correct 636 ms 95056 KB Output is correct
58 Correct 629 ms 94804 KB Output is correct
59 Correct 561 ms 93304 KB Output is correct
60 Correct 572 ms 93268 KB Output is correct
61 Correct 555 ms 90452 KB Output is correct
62 Correct 588 ms 93104 KB Output is correct
63 Correct 395 ms 86564 KB Output is correct
64 Correct 386 ms 86356 KB Output is correct
65 Correct 508 ms 89112 KB Output is correct
66 Correct 529 ms 89044 KB Output is correct
67 Correct 558 ms 89156 KB Output is correct
68 Correct 584 ms 90984 KB Output is correct
69 Correct 633 ms 90940 KB Output is correct
70 Correct 566 ms 90576 KB Output is correct
71 Correct 569 ms 90564 KB Output is correct
72 Correct 583 ms 90448 KB Output is correct
73 Correct 362 ms 82324 KB Output is correct
74 Correct 371 ms 83384 KB Output is correct
75 Correct 361 ms 82760 KB Output is correct
76 Correct 357 ms 82768 KB Output is correct
77 Correct 363 ms 82888 KB Output is correct
78 Correct 523 ms 85036 KB Output is correct
79 Correct 421 ms 77304 KB Output is correct
80 Correct 510 ms 83120 KB Output is correct