Submission #344880

#TimeUsernameProblemLanguageResultExecution timeMemory
344880infertechno2Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
8 / 100
3076 ms33524 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...