답안 #931845

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931845 2024-02-22T12:26:07 Z Aiperiii Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
100 / 100
2220 ms 156296 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
const int N=1e6+5;
int t[N*4],a[N],ans[N];
vector <vector <int> > qu[N];
void update(int v,int tl,int tr,int pos,int val){
    if(tl==tr)t[v]=val;
    else{
        int tm=(tl+tr)/2;
        if(pos<=tm)update(v*2,tl,tm,pos,val);
        else update(v*2+1,tm+1,tr,pos,val);
        t[v]=max(t[v*2],t[v*2+1]);
    }
}
int get(int v,int tl,int tr,int l,int r){
    if(r<tl or tr<l)return INT_MIN;
    if(l<=tl && tr<=r)return t[v];
    int tm=(tl+tr)/2;
    return max(get(v*2,tl,tm,l,r),get(v*2+1,tm+1,tr,l,r));
}
signed main(){
    ios_base::sync_with_stdio();
    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=0;i<q;i++){
        int l,r,x;
        cin>>l>>r>>x;
        qu[r].pb({l,x,i});
    }
    stack <int> st;
    for(int i=1;i<=n;i++){
        while(!st.empty()){
            if(a[st.top()]>a[i])break;
            st.pop();
        }
        if(!st.empty())update(1,1,n,st.top(),a[st.top()]+a[i]);
        for(auto v : qu[i]){
            int mx=get(1,1,n,v[0],i);
            if(mx<=v[1])ans[v[2]]=1;
        }
        st.push(i);
    }
    for(int i=0;i<q;i++)cout<<ans[i]<<"\n";
}
/*

 */

# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 29276 KB Output is correct
2 Correct 6 ms 27264 KB Output is correct
3 Correct 7 ms 29272 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 6 ms 29276 KB Output is correct
6 Correct 7 ms 29296 KB Output is correct
7 Correct 8 ms 29276 KB Output is correct
8 Correct 8 ms 27300 KB Output is correct
9 Correct 7 ms 27228 KB Output is correct
10 Correct 7 ms 27228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 29276 KB Output is correct
2 Correct 6 ms 27264 KB Output is correct
3 Correct 7 ms 29272 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 6 ms 29276 KB Output is correct
6 Correct 7 ms 29296 KB Output is correct
7 Correct 8 ms 29276 KB Output is correct
8 Correct 8 ms 27300 KB Output is correct
9 Correct 7 ms 27228 KB Output is correct
10 Correct 7 ms 27228 KB Output is correct
11 Correct 12 ms 29416 KB Output is correct
12 Correct 11 ms 31580 KB Output is correct
13 Correct 11 ms 31580 KB Output is correct
14 Correct 14 ms 31836 KB Output is correct
15 Correct 18 ms 31748 KB Output is correct
16 Correct 12 ms 27748 KB Output is correct
17 Correct 10 ms 27484 KB Output is correct
18 Correct 16 ms 27648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1940 ms 134092 KB Output is correct
2 Correct 1954 ms 134148 KB Output is correct
3 Correct 1982 ms 138340 KB Output is correct
4 Correct 2017 ms 136112 KB Output is correct
5 Correct 1834 ms 122084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 39236 KB Output is correct
2 Correct 129 ms 39992 KB Output is correct
3 Correct 119 ms 35668 KB Output is correct
4 Correct 119 ms 35664 KB Output is correct
5 Correct 120 ms 35920 KB Output is correct
6 Correct 107 ms 39452 KB Output is correct
7 Correct 108 ms 39508 KB Output is correct
8 Correct 105 ms 35592 KB Output is correct
9 Correct 74 ms 34568 KB Output is correct
10 Correct 106 ms 35512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 29276 KB Output is correct
2 Correct 6 ms 27264 KB Output is correct
3 Correct 7 ms 29272 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 6 ms 29276 KB Output is correct
6 Correct 7 ms 29296 KB Output is correct
7 Correct 8 ms 29276 KB Output is correct
8 Correct 8 ms 27300 KB Output is correct
9 Correct 7 ms 27228 KB Output is correct
10 Correct 7 ms 27228 KB Output is correct
11 Correct 12 ms 29416 KB Output is correct
12 Correct 11 ms 31580 KB Output is correct
13 Correct 11 ms 31580 KB Output is correct
14 Correct 14 ms 31836 KB Output is correct
15 Correct 18 ms 31748 KB Output is correct
16 Correct 12 ms 27748 KB Output is correct
17 Correct 10 ms 27484 KB Output is correct
18 Correct 16 ms 27648 KB Output is correct
19 Correct 341 ms 55168 KB Output is correct
20 Correct 348 ms 55444 KB Output is correct
21 Correct 300 ms 55376 KB Output is correct
22 Correct 314 ms 55376 KB Output is correct
23 Correct 306 ms 55160 KB Output is correct
24 Correct 273 ms 48980 KB Output is correct
25 Correct 270 ms 48980 KB Output is correct
26 Correct 294 ms 48980 KB Output is correct
27 Correct 297 ms 49140 KB Output is correct
28 Correct 310 ms 48980 KB Output is correct
29 Correct 314 ms 49060 KB Output is correct
30 Correct 307 ms 49136 KB Output is correct
31 Correct 319 ms 49456 KB Output is correct
32 Correct 313 ms 49236 KB Output is correct
33 Correct 316 ms 48952 KB Output is correct
34 Correct 270 ms 52308 KB Output is correct
35 Correct 266 ms 52308 KB Output is correct
36 Correct 262 ms 52228 KB Output is correct
37 Correct 266 ms 52100 KB Output is correct
38 Correct 279 ms 52488 KB Output is correct
39 Correct 263 ms 48388 KB Output is correct
40 Correct 213 ms 46076 KB Output is correct
41 Correct 252 ms 46592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 29276 KB Output is correct
2 Correct 6 ms 27264 KB Output is correct
3 Correct 7 ms 29272 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 6 ms 29276 KB Output is correct
6 Correct 7 ms 29296 KB Output is correct
7 Correct 8 ms 29276 KB Output is correct
8 Correct 8 ms 27300 KB Output is correct
9 Correct 7 ms 27228 KB Output is correct
10 Correct 7 ms 27228 KB Output is correct
11 Correct 12 ms 29416 KB Output is correct
12 Correct 11 ms 31580 KB Output is correct
13 Correct 11 ms 31580 KB Output is correct
14 Correct 14 ms 31836 KB Output is correct
15 Correct 18 ms 31748 KB Output is correct
16 Correct 12 ms 27748 KB Output is correct
17 Correct 10 ms 27484 KB Output is correct
18 Correct 16 ms 27648 KB Output is correct
19 Correct 1940 ms 134092 KB Output is correct
20 Correct 1954 ms 134148 KB Output is correct
21 Correct 1982 ms 138340 KB Output is correct
22 Correct 2017 ms 136112 KB Output is correct
23 Correct 1834 ms 122084 KB Output is correct
24 Correct 133 ms 39236 KB Output is correct
25 Correct 129 ms 39992 KB Output is correct
26 Correct 119 ms 35668 KB Output is correct
27 Correct 119 ms 35664 KB Output is correct
28 Correct 120 ms 35920 KB Output is correct
29 Correct 107 ms 39452 KB Output is correct
30 Correct 108 ms 39508 KB Output is correct
31 Correct 105 ms 35592 KB Output is correct
32 Correct 74 ms 34568 KB Output is correct
33 Correct 106 ms 35512 KB Output is correct
34 Correct 341 ms 55168 KB Output is correct
35 Correct 348 ms 55444 KB Output is correct
36 Correct 300 ms 55376 KB Output is correct
37 Correct 314 ms 55376 KB Output is correct
38 Correct 306 ms 55160 KB Output is correct
39 Correct 273 ms 48980 KB Output is correct
40 Correct 270 ms 48980 KB Output is correct
41 Correct 294 ms 48980 KB Output is correct
42 Correct 297 ms 49140 KB Output is correct
43 Correct 310 ms 48980 KB Output is correct
44 Correct 314 ms 49060 KB Output is correct
45 Correct 307 ms 49136 KB Output is correct
46 Correct 319 ms 49456 KB Output is correct
47 Correct 313 ms 49236 KB Output is correct
48 Correct 316 ms 48952 KB Output is correct
49 Correct 270 ms 52308 KB Output is correct
50 Correct 266 ms 52308 KB Output is correct
51 Correct 262 ms 52228 KB Output is correct
52 Correct 266 ms 52100 KB Output is correct
53 Correct 279 ms 52488 KB Output is correct
54 Correct 263 ms 48388 KB Output is correct
55 Correct 213 ms 46076 KB Output is correct
56 Correct 252 ms 46592 KB Output is correct
57 Correct 1980 ms 155444 KB Output is correct
58 Correct 1948 ms 155948 KB Output is correct
59 Correct 1897 ms 156224 KB Output is correct
60 Correct 1925 ms 156296 KB Output is correct
61 Correct 1905 ms 156244 KB Output is correct
62 Correct 1888 ms 156180 KB Output is correct
63 Correct 1540 ms 137788 KB Output is correct
64 Correct 1550 ms 138088 KB Output is correct
65 Correct 1770 ms 139764 KB Output is correct
66 Correct 1788 ms 139392 KB Output is correct
67 Correct 2220 ms 139360 KB Output is correct
68 Correct 1923 ms 139200 KB Output is correct
69 Correct 1911 ms 138952 KB Output is correct
70 Correct 1899 ms 139244 KB Output is correct
71 Correct 1880 ms 139268 KB Output is correct
72 Correct 1918 ms 139308 KB Output is correct
73 Correct 1571 ms 136908 KB Output is correct
74 Correct 1531 ms 138024 KB Output is correct
75 Correct 1484 ms 137048 KB Output is correct
76 Correct 1481 ms 137448 KB Output is correct
77 Correct 1505 ms 136772 KB Output is correct
78 Correct 1595 ms 136732 KB Output is correct
79 Correct 1228 ms 121324 KB Output is correct
80 Correct 1448 ms 128432 KB Output is correct