답안 #944040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944040 2024-03-12T07:26:08 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
100 / 100
735 ms 77656 KB
#include<bits/stdc++.h>
#define X s.top()
#define K 1<<20
using namespace std;
vector<tuple<int,int,int>>q[1<<20];
int n,a[1<<20],t[1<<20],m,r[1<<20];
void upd(int x,int v){
    for(;x;x-=x&-x)
        t[x]=max(t[x],v);
}
int qu(int x){
    int v=0;
    for(;x<=n;x+=x&-x)
        v=max(t[x],v);
    return v;
}
stack<int>s;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    a[0]=2e9,s.push(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0,a,b,c;i<m;i++)
        cin>>a>>b>>c,q[b].push_back({a,c,i});
    for(int i=1;i<=n;i++){
        while(a[X]<=a[i])
            s.pop();
        if(X) upd(X,a[X]+a[i]);
        s.push(i);
        for(auto[a,b,c]:q[i])
            r[c]=qu(a)<=b;
    }
    for(int i=0;i<m;i++)
        cout<<r[i]<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 30812 KB Output is correct
2 Correct 7 ms 30812 KB Output is correct
3 Correct 8 ms 31064 KB Output is correct
4 Correct 7 ms 31068 KB Output is correct
5 Correct 7 ms 30812 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 9 ms 31068 KB Output is correct
8 Correct 7 ms 31064 KB Output is correct
9 Correct 7 ms 31064 KB Output is correct
10 Correct 7 ms 31068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 30812 KB Output is correct
2 Correct 7 ms 30812 KB Output is correct
3 Correct 8 ms 31064 KB Output is correct
4 Correct 7 ms 31068 KB Output is correct
5 Correct 7 ms 30812 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 9 ms 31068 KB Output is correct
8 Correct 7 ms 31064 KB Output is correct
9 Correct 7 ms 31064 KB Output is correct
10 Correct 7 ms 31068 KB Output is correct
11 Correct 8 ms 31068 KB Output is correct
12 Correct 10 ms 31068 KB Output is correct
13 Correct 9 ms 31060 KB Output is correct
14 Correct 11 ms 31196 KB Output is correct
15 Correct 10 ms 31576 KB Output is correct
16 Correct 9 ms 31064 KB Output is correct
17 Correct 8 ms 31068 KB Output is correct
18 Correct 9 ms 31068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 702 ms 77136 KB Output is correct
2 Correct 689 ms 77656 KB Output is correct
3 Correct 683 ms 77648 KB Output is correct
4 Correct 735 ms 77656 KB Output is correct
5 Correct 671 ms 75480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 38964 KB Output is correct
2 Correct 46 ms 38668 KB Output is correct
3 Correct 47 ms 38740 KB Output is correct
4 Correct 47 ms 38704 KB Output is correct
5 Correct 48 ms 38896 KB Output is correct
6 Correct 49 ms 38320 KB Output is correct
7 Correct 37 ms 38480 KB Output is correct
8 Correct 55 ms 38412 KB Output is correct
9 Correct 35 ms 35876 KB Output is correct
10 Correct 66 ms 38396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 30812 KB Output is correct
2 Correct 7 ms 30812 KB Output is correct
3 Correct 8 ms 31064 KB Output is correct
4 Correct 7 ms 31068 KB Output is correct
5 Correct 7 ms 30812 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 9 ms 31068 KB Output is correct
8 Correct 7 ms 31064 KB Output is correct
9 Correct 7 ms 31064 KB Output is correct
10 Correct 7 ms 31068 KB Output is correct
11 Correct 8 ms 31068 KB Output is correct
12 Correct 10 ms 31068 KB Output is correct
13 Correct 9 ms 31060 KB Output is correct
14 Correct 11 ms 31196 KB Output is correct
15 Correct 10 ms 31576 KB Output is correct
16 Correct 9 ms 31064 KB Output is correct
17 Correct 8 ms 31068 KB Output is correct
18 Correct 9 ms 31068 KB Output is correct
19 Correct 145 ms 43912 KB Output is correct
20 Correct 148 ms 44196 KB Output is correct
21 Correct 90 ms 43456 KB Output is correct
22 Correct 93 ms 43664 KB Output is correct
23 Correct 118 ms 43604 KB Output is correct
24 Correct 95 ms 42496 KB Output is correct
25 Correct 105 ms 42624 KB Output is correct
26 Correct 116 ms 43092 KB Output is correct
27 Correct 90 ms 43128 KB Output is correct
28 Correct 96 ms 43180 KB Output is correct
29 Correct 96 ms 43344 KB Output is correct
30 Correct 120 ms 43352 KB Output is correct
31 Correct 109 ms 43468 KB Output is correct
32 Correct 120 ms 43352 KB Output is correct
33 Correct 116 ms 43392 KB Output is correct
34 Correct 82 ms 42324 KB Output is correct
35 Correct 92 ms 42320 KB Output is correct
36 Correct 80 ms 42252 KB Output is correct
37 Correct 83 ms 42420 KB Output is correct
38 Correct 79 ms 42196 KB Output is correct
39 Correct 120 ms 42620 KB Output is correct
40 Correct 85 ms 41656 KB Output is correct
41 Correct 87 ms 41988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 30812 KB Output is correct
2 Correct 7 ms 30812 KB Output is correct
3 Correct 8 ms 31064 KB Output is correct
4 Correct 7 ms 31068 KB Output is correct
5 Correct 7 ms 30812 KB Output is correct
6 Correct 7 ms 31068 KB Output is correct
7 Correct 9 ms 31068 KB Output is correct
8 Correct 7 ms 31064 KB Output is correct
9 Correct 7 ms 31064 KB Output is correct
10 Correct 7 ms 31068 KB Output is correct
11 Correct 8 ms 31068 KB Output is correct
12 Correct 10 ms 31068 KB Output is correct
13 Correct 9 ms 31060 KB Output is correct
14 Correct 11 ms 31196 KB Output is correct
15 Correct 10 ms 31576 KB Output is correct
16 Correct 9 ms 31064 KB Output is correct
17 Correct 8 ms 31068 KB Output is correct
18 Correct 9 ms 31068 KB Output is correct
19 Correct 702 ms 77136 KB Output is correct
20 Correct 689 ms 77656 KB Output is correct
21 Correct 683 ms 77648 KB Output is correct
22 Correct 735 ms 77656 KB Output is correct
23 Correct 671 ms 75480 KB Output is correct
24 Correct 53 ms 38964 KB Output is correct
25 Correct 46 ms 38668 KB Output is correct
26 Correct 47 ms 38740 KB Output is correct
27 Correct 47 ms 38704 KB Output is correct
28 Correct 48 ms 38896 KB Output is correct
29 Correct 49 ms 38320 KB Output is correct
30 Correct 37 ms 38480 KB Output is correct
31 Correct 55 ms 38412 KB Output is correct
32 Correct 35 ms 35876 KB Output is correct
33 Correct 66 ms 38396 KB Output is correct
34 Correct 145 ms 43912 KB Output is correct
35 Correct 148 ms 44196 KB Output is correct
36 Correct 90 ms 43456 KB Output is correct
37 Correct 93 ms 43664 KB Output is correct
38 Correct 118 ms 43604 KB Output is correct
39 Correct 95 ms 42496 KB Output is correct
40 Correct 105 ms 42624 KB Output is correct
41 Correct 116 ms 43092 KB Output is correct
42 Correct 90 ms 43128 KB Output is correct
43 Correct 96 ms 43180 KB Output is correct
44 Correct 96 ms 43344 KB Output is correct
45 Correct 120 ms 43352 KB Output is correct
46 Correct 109 ms 43468 KB Output is correct
47 Correct 120 ms 43352 KB Output is correct
48 Correct 116 ms 43392 KB Output is correct
49 Correct 82 ms 42324 KB Output is correct
50 Correct 92 ms 42320 KB Output is correct
51 Correct 80 ms 42252 KB Output is correct
52 Correct 83 ms 42420 KB Output is correct
53 Correct 79 ms 42196 KB Output is correct
54 Correct 120 ms 42620 KB Output is correct
55 Correct 85 ms 41656 KB Output is correct
56 Correct 87 ms 41988 KB Output is correct
57 Correct 681 ms 77392 KB Output is correct
58 Correct 690 ms 77488 KB Output is correct
59 Correct 651 ms 75928 KB Output is correct
60 Correct 647 ms 76036 KB Output is correct
61 Correct 569 ms 75856 KB Output is correct
62 Correct 640 ms 75792 KB Output is correct
63 Correct 379 ms 71640 KB Output is correct
64 Correct 392 ms 71588 KB Output is correct
65 Correct 559 ms 73816 KB Output is correct
66 Correct 530 ms 57172 KB Output is correct
67 Correct 609 ms 56848 KB Output is correct
68 Correct 642 ms 58560 KB Output is correct
69 Correct 670 ms 58444 KB Output is correct
70 Correct 645 ms 58196 KB Output is correct
71 Correct 692 ms 58252 KB Output is correct
72 Correct 707 ms 58156 KB Output is correct
73 Correct 378 ms 53324 KB Output is correct
74 Correct 371 ms 53076 KB Output is correct
75 Correct 344 ms 53000 KB Output is correct
76 Correct 353 ms 53076 KB Output is correct
77 Correct 354 ms 53416 KB Output is correct
78 Correct 584 ms 57600 KB Output is correct
79 Correct 450 ms 54400 KB Output is correct
80 Correct 536 ms 57112 KB Output is correct