# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498799 | Abdurahmon | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 0 ms | 0 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>
using namespace std;
typedef long long ll;
#pragma GCC target ("avx2");
#pragma GCC optimization ("O3");
#pragma GCC optimization ("unroll-loops");
ll t[1000000];
void solve()
{
int l,r,k;ll m=0;
cin>>l>>r>>k;
l--;r--;
for(int c=l;c<=r;c++)
{
if(t[c]<m)
{
if(t[c]+m>k&&c>0)
{
cout<<"0\n";return;
}
}
else
{
m=t[c];
}
}
cout<<"1\n";
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n,m;
cin>>n>>m;
for(int c=0;c<n;c++)
{
cin>>t[c];
}
while(m--)
{
solve();
}
}