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;
const int N=1e6+10;
int a[N];
bool sorted[N];
int main() {
int n,m;
cin>>n>>m;
sorted[0]=true;
for(int i=1; i<=n; i++)
{
cin>>a[i];
if(sorted[i-1] && a[i] >= a[i-1])sorted[i]=true;
}
for(int i=1; i<=m; i++){
int l,r,k;
cin>>l>>r>>k;
bool ans=true;
if(sorted[r]){
cout<<ans;
continue;
}
for(int i=l; i<r; i++){
if(a[i] > a[i+1]){
ans=false;
break;
}
}
cout<<ans<<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... |