이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<pi> vpi;
#define pb emplace_back
#define mp make_pair
#define f first
#define s second
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define lb lower_bound
const int MAXN=1001000;
const ll MOD=998244353;
int A[MAXN];
int N,Q,a,b,c;
struct node{
int s,e,m,v;
node *l,*r;
node(int _s,int _e):s(_s),e(_e){
m=(s+e)/2;v=0;
if(s!=e){
l=new node(s,m);
r=new node(m+1,e);
v=max(l->v,r->v);
}
}
int ask(int a,int b){
if(a==s&&e==b)return v;
if(b<=m)return l->ask(a,b);
if(a>m)return r->ask(a,b);
return max(l->ask(a,m),r->ask(m+1,b));
}
}*maxes;
int fs[MAXN];
vpi V;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>N>>Q;
for(int i=1;i<=N;++i){
cin>>A[i];
}
stack<int> S;
for(int i=1;i<=N;++i){
while(SZ(S) && A[S.top()] <= A[i]){
// cerr<<"Inversion "<<S.top()<<' '<<i<<'\n';
S.pop();
}
if(SZ(S)){
V.pb(S.top(),i);
// cerr<<"Inversion "<<S.top()<<' '<<i<<'\n';
}
S.push(i);
}
while(Q--){
cin>>a>>b>>c;
int fail=0;
for(auto i:V){
if(i.f >= a && i.s <= b && A[i.f] + A[i.s] > c){
fail=1;
}
}
if(fail)cout<<"0\n";
else cout<<"1\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |