답안 #206797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206797 2020-03-05T11:17:55 Z brcode Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
1963 ms 142200 KB
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
const long long MAXN = 1e6+1;
long long seg[4*MAXN];
long long n,m;

long long l[MAXN];
long long r[MAXN];
vector<vector<long long>> v1(MAXN);
long long arr[MAXN];
long long k[MAXN];
long long pos[MAXN];
long long ans[MAXN];
void update(long long curr,long long l,long long r,long long ind,long long val){
    if(l==r){
        seg[curr] = val;
        return;
    }
    long long mid = (l+r)/2;
    if(ind<=mid){
        update(2*curr,l,mid,ind,val);
    }else{
        update(2*curr+1,mid+1,r,ind,val);
    }
    seg[curr] = max(seg[2*curr],seg[2*curr+1]);
}
long long query(long long curr,long long l,long long r,long long tl,long long tr){
    if(l>tr||r<tl){
        return 0;
    }
    if(l>=tl && r<=tr){
        return seg[curr];
    }
    long long mid = (l+r)/2;
    return max(query(2*curr,l,mid,tl,tr),query(2*curr+1,mid+1,r,tl,tr));
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
        pos[i] = i-1;
        while(pos[i] && arr[pos[i]]<=arr[i]){
            pos[i] = pos[pos[i]];
        }
    }
    for(long long i=1;i<=m;i++){
        cin>>l[i]>>r[i]>>k[i];
        v1[r[i]].push_back(i);
    }
    for(long long i=1;i<=n;i++){
        if(pos[i]){
            update(1,1,n,pos[i],arr[i]+arr[pos[i]]);
            
        }
        for(long long x:v1[i]){
                ans[x]=(query(1,1,n,l[x],r[x])<=k[x]);
            }
        
    }
    for(long long i=1;i<=m;i++){
        cout<<ans[i]<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 23928 KB Output is correct
2 Correct 19 ms 23928 KB Output is correct
3 Correct 18 ms 23932 KB Output is correct
4 Correct 19 ms 23928 KB Output is correct
5 Correct 20 ms 23928 KB Output is correct
6 Correct 20 ms 23928 KB Output is correct
7 Correct 19 ms 23928 KB Output is correct
8 Correct 25 ms 23928 KB Output is correct
9 Correct 19 ms 23928 KB Output is correct
10 Correct 19 ms 23928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 23928 KB Output is correct
2 Correct 19 ms 23928 KB Output is correct
3 Correct 18 ms 23932 KB Output is correct
4 Correct 19 ms 23928 KB Output is correct
5 Correct 20 ms 23928 KB Output is correct
6 Correct 20 ms 23928 KB Output is correct
7 Correct 19 ms 23928 KB Output is correct
8 Correct 25 ms 23928 KB Output is correct
9 Correct 19 ms 23928 KB Output is correct
10 Correct 19 ms 23928 KB Output is correct
11 Correct 21 ms 24184 KB Output is correct
12 Correct 22 ms 24312 KB Output is correct
13 Correct 23 ms 24312 KB Output is correct
14 Correct 24 ms 24440 KB Output is correct
15 Correct 27 ms 24440 KB Output is correct
16 Correct 22 ms 24312 KB Output is correct
17 Correct 24 ms 24312 KB Output is correct
18 Correct 23 ms 24344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1866 ms 109140 KB Output is correct
2 Correct 1944 ms 142200 KB Output is correct
3 Correct 1963 ms 141864 KB Output is correct
4 Correct 1952 ms 142088 KB Output is correct
5 Correct 1564 ms 125684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 33376 KB Output is correct
2 Correct 136 ms 32888 KB Output is correct
3 Correct 120 ms 31096 KB Output is correct
4 Correct 120 ms 31224 KB Output is correct
5 Correct 120 ms 31396 KB Output is correct
6 Correct 98 ms 30584 KB Output is correct
7 Correct 96 ms 30584 KB Output is correct
8 Correct 108 ms 31192 KB Output is correct
9 Correct 64 ms 28784 KB Output is correct
10 Correct 109 ms 31216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 23928 KB Output is correct
2 Correct 19 ms 23928 KB Output is correct
3 Correct 18 ms 23932 KB Output is correct
4 Correct 19 ms 23928 KB Output is correct
5 Correct 20 ms 23928 KB Output is correct
6 Correct 20 ms 23928 KB Output is correct
7 Correct 19 ms 23928 KB Output is correct
8 Correct 25 ms 23928 KB Output is correct
9 Correct 19 ms 23928 KB Output is correct
10 Correct 19 ms 23928 KB Output is correct
11 Correct 21 ms 24184 KB Output is correct
12 Correct 22 ms 24312 KB Output is correct
13 Correct 23 ms 24312 KB Output is correct
14 Correct 24 ms 24440 KB Output is correct
15 Correct 27 ms 24440 KB Output is correct
16 Correct 22 ms 24312 KB Output is correct
17 Correct 24 ms 24312 KB Output is correct
18 Correct 23 ms 24344 KB Output is correct
19 Correct 324 ms 42208 KB Output is correct
20 Correct 335 ms 42232 KB Output is correct
21 Correct 267 ms 41080 KB Output is correct
22 Correct 270 ms 40952 KB Output is correct
23 Correct 274 ms 41252 KB Output is correct
24 Correct 235 ms 36728 KB Output is correct
25 Correct 227 ms 36728 KB Output is correct
26 Correct 263 ms 37240 KB Output is correct
27 Correct 243 ms 37240 KB Output is correct
28 Correct 253 ms 37496 KB Output is correct
29 Correct 272 ms 37880 KB Output is correct
30 Correct 274 ms 38008 KB Output is correct
31 Correct 275 ms 37880 KB Output is correct
32 Correct 267 ms 37880 KB Output is correct
33 Correct 274 ms 37880 KB Output is correct
34 Correct 205 ms 36472 KB Output is correct
35 Correct 214 ms 36472 KB Output is correct
36 Correct 210 ms 36472 KB Output is correct
37 Correct 209 ms 36476 KB Output is correct
38 Correct 215 ms 36472 KB Output is correct
39 Correct 248 ms 39024 KB Output is correct
40 Correct 187 ms 36204 KB Output is correct
41 Correct 232 ms 37868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 23928 KB Output is correct
2 Correct 19 ms 23928 KB Output is correct
3 Correct 18 ms 23932 KB Output is correct
4 Correct 19 ms 23928 KB Output is correct
5 Correct 20 ms 23928 KB Output is correct
6 Correct 20 ms 23928 KB Output is correct
7 Correct 19 ms 23928 KB Output is correct
8 Correct 25 ms 23928 KB Output is correct
9 Correct 19 ms 23928 KB Output is correct
10 Correct 19 ms 23928 KB Output is correct
11 Correct 21 ms 24184 KB Output is correct
12 Correct 22 ms 24312 KB Output is correct
13 Correct 23 ms 24312 KB Output is correct
14 Correct 24 ms 24440 KB Output is correct
15 Correct 27 ms 24440 KB Output is correct
16 Correct 22 ms 24312 KB Output is correct
17 Correct 24 ms 24312 KB Output is correct
18 Correct 23 ms 24344 KB Output is correct
19 Correct 1866 ms 109140 KB Output is correct
20 Correct 1944 ms 142200 KB Output is correct
21 Correct 1963 ms 141864 KB Output is correct
22 Correct 1952 ms 142088 KB Output is correct
23 Correct 1564 ms 125684 KB Output is correct
24 Correct 151 ms 33376 KB Output is correct
25 Correct 136 ms 32888 KB Output is correct
26 Correct 120 ms 31096 KB Output is correct
27 Correct 120 ms 31224 KB Output is correct
28 Correct 120 ms 31396 KB Output is correct
29 Correct 98 ms 30584 KB Output is correct
30 Correct 96 ms 30584 KB Output is correct
31 Correct 108 ms 31192 KB Output is correct
32 Correct 64 ms 28784 KB Output is correct
33 Correct 109 ms 31216 KB Output is correct
34 Correct 324 ms 42208 KB Output is correct
35 Correct 335 ms 42232 KB Output is correct
36 Correct 267 ms 41080 KB Output is correct
37 Correct 270 ms 40952 KB Output is correct
38 Correct 274 ms 41252 KB Output is correct
39 Correct 235 ms 36728 KB Output is correct
40 Correct 227 ms 36728 KB Output is correct
41 Correct 263 ms 37240 KB Output is correct
42 Correct 243 ms 37240 KB Output is correct
43 Correct 253 ms 37496 KB Output is correct
44 Correct 272 ms 37880 KB Output is correct
45 Correct 274 ms 38008 KB Output is correct
46 Correct 275 ms 37880 KB Output is correct
47 Correct 267 ms 37880 KB Output is correct
48 Correct 274 ms 37880 KB Output is correct
49 Correct 205 ms 36472 KB Output is correct
50 Correct 214 ms 36472 KB Output is correct
51 Correct 210 ms 36472 KB Output is correct
52 Correct 209 ms 36476 KB Output is correct
53 Correct 215 ms 36472 KB Output is correct
54 Correct 248 ms 39024 KB Output is correct
55 Correct 187 ms 36204 KB Output is correct
56 Correct 232 ms 37868 KB Output is correct
57 Correct 1946 ms 141624 KB Output is correct
58 Correct 1957 ms 141756 KB Output is correct
59 Correct 1847 ms 138900 KB Output is correct
60 Correct 1829 ms 139128 KB Output is correct
61 Correct 1795 ms 138944 KB Output is correct
62 Correct 1814 ms 138988 KB Output is correct
63 Correct 1152 ms 116468 KB Output is correct
64 Correct 1166 ms 116560 KB Output is correct
65 Correct 1540 ms 122152 KB Output is correct
66 Correct 1569 ms 121908 KB Output is correct
67 Correct 1520 ms 122160 KB Output is correct
68 Correct 1593 ms 125216 KB Output is correct
69 Correct 1578 ms 125148 KB Output is correct
70 Correct 1545 ms 124696 KB Output is correct
71 Correct 1570 ms 124388 KB Output is correct
72 Correct 1555 ms 124524 KB Output is correct
73 Correct 1118 ms 113604 KB Output is correct
74 Correct 1136 ms 114888 KB Output is correct
75 Correct 1103 ms 113848 KB Output is correct
76 Correct 1130 ms 113780 KB Output is correct
77 Correct 1118 ms 113524 KB Output is correct
78 Correct 1354 ms 122628 KB Output is correct
79 Correct 984 ms 102704 KB Output is correct
80 Correct 1322 ms 114580 KB Output is correct