# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
928197 | vjudge1 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 81 ms | 16972 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 S second
#define F first
#define sz size()
#define int long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define yes "YES\n"
#define no "NO\n"
#define ent "\n"
#define give_me_more_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn = 1e5 + 5 , mod = 1e9 + 7;
void solve(){
int n , q;
cin >> n >> q;
int a[n + 5];
for(int i = 1;i <= n;i++) cin >> a[i];
while(q--){
int l , r , k;
cin >> l >> r >> k;
vector <int> ans , v;
for(int i = l;i <= r;i++){
ans.pb(a[i]);
v.pb(a[i]);
}
sort(all(v));
int ok = 1;
int pos = 0;
for(int i = 0;i < v.size();i++){
while(v[i] != ans[pos]){
if(v[i] + ans[pos] > k){
ok = 0;
}
pos++;
}
if(ok == 1){
rotate(ans.begin() , --ans.begin() + pos , ans.end());
}
}
cout<<ok<<ent;
}
}
signed main(){
give_me_more_speed
int t = 1;
//cin>>t;
for(int i = 1;i <= t;i++){
solve();
}
}
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... |