# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931751 | Aiperiii | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 3049 ms | 32940 KiB |
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 int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,q;
cin>>n>>q;
vector <int> a(n+1);
for(int i=1;i<=n;i++)cin>>a[i];
while(q--){
int l,r,x;
cin>>l>>r>>x;
vector <int> v;
for(int i=l;i<=r;i++)v.pb(a[i]);
bool ok=1;
for(int i=0;i<v.size();i++){
for(int j=0;j<v.size()-i-1;j++){
if(v[j]>v[j+1]){
swap(v[j],v[j+1]);
if(x<v[j]+v[j+1]){
ok=0;break;
}
}
}
}
cout<<ok<<"\n";
}
}
/*
5 2
3 5 1 8 2
1 3 6
2 5 3
*/
Compilation message (stderr)
# | 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... |