Submission #892846

# Submission time Handle Problem Language Result Execution time Memory
892846 2023-12-26T05:10:05 Z vjudge1 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
1344 ms 170000 KB
#include<bits/stdc++.h>
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define vl vector<ll>
#define vll vector<pll>
#define vlll vector<plll>
#define vllll vector<pllll>
#define vb vector<bool>
#define sz size()
#define fr front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bk back();
using namespace std;
const ld pi=3.14159265359;
const ll e5=1e5;
const ll e6=1e6;
const ll e9=1e9;
const ll inf=1e18;
const ll mod=1e9+7;
const ll mod2=998244353;
const ll N=2e6+5;
ll bpm(ll x,ll y,ll m){if(y==0)return 1%m;if(y==1)return x%m;ll p=bpm(x,y/2,m);
if(y%2==0)return p*p%m;else return p*p%m*x%m;}
ll bp(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll p=bp(x,y/2);
if(y%2==0)return p*p;else return p*p*x;}
ll n,m,a[N],p[N],ql[N],qr[N],qk[N],t[N*4];
bool ans[N];
vl q[N];
void upd(ll v,ll l,ll r,ll i,ll x){
    if(l==r){
        t[v]=x;
        return;
    }
    ll m=(l+r)/2;
    if(i<=m) upd(v*2,l,m,i,x);
    else upd(v*2+1,m+1,r,i,x);
    t[v]=max(t[v*2],t[v*2+1]);
}
ll get(ll v,ll l,ll r,ll ql,ll qr){
    if(qr<l||r<ql) return 0;
    if(ql<=l&&r<=qr) return t[v];
    ll m=(l+r)/2;
    ll m1=get(v*2,l,m,ql,qr);
    ll m2=get(v*2+1,m+1,r,ql,qr);
    return max(m1,m2);
}
void solve(){
    cin>>n>>m;
    stack<ll> s;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        while(!s.empty()&&a[s.top()]<a[i]) s.pop();
        if(!s.empty()) p[i]=s.top();
        s.push(i);
    }
    for(ll i=1;i<=m;i++){
        cin>>ql[i]>>qr[i]>>qk[i];
        q[qr[i]].pb(i);
    }
    for(ll i=1;i<=n;i++){
        if(p[i]!=0) upd(1,1,n,p[i],a[p[i]]+a[i]);
        for(ll j:q[i]){
           ans[j] = get(1,1,n,ql[j],qr[j]) <= qk[j];
        }
    }
    for(ll i=1;i<=m;i++){
        if(ans[i]) cout<<1<<'\n';
        else cout<<0<<'\n';
    }
    return;
}
int main(/*Aldk*/){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);    
    //cout<<setprecision(6)<<fixed;
    ll T=1;
    //cin>>T;
    for(ll i=1;i<=T;i++){
        //cout<<"Scenario #"<<i<<":\n";
        solve();
        //cout<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 59996 KB Output is correct
2 Correct 12 ms 55896 KB Output is correct
3 Correct 12 ms 59996 KB Output is correct
4 Correct 12 ms 59996 KB Output is correct
5 Correct 11 ms 59996 KB Output is correct
6 Correct 12 ms 59996 KB Output is correct
7 Correct 12 ms 60084 KB Output is correct
8 Correct 12 ms 58100 KB Output is correct
9 Correct 11 ms 57944 KB Output is correct
10 Incorrect 12 ms 57948 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 59996 KB Output is correct
2 Correct 12 ms 55896 KB Output is correct
3 Correct 12 ms 59996 KB Output is correct
4 Correct 12 ms 59996 KB Output is correct
5 Correct 11 ms 59996 KB Output is correct
6 Correct 12 ms 59996 KB Output is correct
7 Correct 12 ms 60084 KB Output is correct
8 Correct 12 ms 58100 KB Output is correct
9 Correct 11 ms 57944 KB Output is correct
10 Incorrect 12 ms 57948 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1242 ms 169004 KB Output is correct
2 Correct 1230 ms 170000 KB Output is correct
3 Correct 1344 ms 169812 KB Output is correct
4 Correct 1208 ms 169848 KB Output is correct
5 Incorrect 1123 ms 169428 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 70140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 59996 KB Output is correct
2 Correct 12 ms 55896 KB Output is correct
3 Correct 12 ms 59996 KB Output is correct
4 Correct 12 ms 59996 KB Output is correct
5 Correct 11 ms 59996 KB Output is correct
6 Correct 12 ms 59996 KB Output is correct
7 Correct 12 ms 60084 KB Output is correct
8 Correct 12 ms 58100 KB Output is correct
9 Correct 11 ms 57944 KB Output is correct
10 Incorrect 12 ms 57948 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 59996 KB Output is correct
2 Correct 12 ms 55896 KB Output is correct
3 Correct 12 ms 59996 KB Output is correct
4 Correct 12 ms 59996 KB Output is correct
5 Correct 11 ms 59996 KB Output is correct
6 Correct 12 ms 59996 KB Output is correct
7 Correct 12 ms 60084 KB Output is correct
8 Correct 12 ms 58100 KB Output is correct
9 Correct 11 ms 57944 KB Output is correct
10 Incorrect 12 ms 57948 KB Output isn't correct
11 Halted 0 ms 0 KB -