This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define N 1000005
#define INF 1e9+5
#define sp " "
#define endl "\n"
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
int n,m,l,r,k;
int main(){
cin >> n >> m;
vector<int> w(n+1);
vector<int> s(n+1);
for(int i=1;i<=n;i++){
cin >> w[i];
}
for(int i=1;i<=m;i++){
cin >> l >> r >> k;
int mx=0;
for(int j=l;j<=r;j++){
s[j]=w[j];
}
for(int j=l;j<=r;j++){
int h=j;
while(h>=l&&s[h]<s[h-1]){
swap(s[h],s[h-1]);
mx=max(mx,s[h-1]+s[h]);
h--;
}
}
if(mx<=k)
cout << 1 << endl;
else
cout << 0 << endl;
}
}
# | 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... |