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>
using namespace std;
typedef long long ll;
ll book_weight[1000001];
int main(){
ll n,m;
cin>>n>>m;
for(ll i=0;i<n;i++){
cin>>book_weight[i];
}
for(ll i=0;i<m;i++){
ll l,r,k;
cin>>l>>r>>k;
l--; r--;
vector<ll> books_sorted;
books_sorted.push_back(book_weight[l]);
bool is_possible=true;
for(ll j=1;j<=r-l;j++){
books_sorted.push_back(book_weight[l+j]);
ll x=j;
while(books_sorted[x]<books_sorted[x-1]){
if(k<books_sorted[x]+books_sorted[x-1]){
is_possible=false;
break;
}
swap(books_sorted[x],books_sorted[x-1]);
x--;
if(x==0)break;
}
}
if(is_possible){
cout<<1<<endl;
}else{
cout<<0<<endl;
}
}
return 0;
}
# | 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... |