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 endl "\n"
using namespace std;
const int maxn = 1e6+5;
int n,m;
int w[maxn],pref[maxn];
bool check(int l, int r, int k)
{
int maxch = 0;
int razmqna = 0;
for(int i = l; i <= r; i++)
{
if(maxch>w[i]) razmqna = max(razmqna,maxch+w[i]);
maxch = max(maxch,w[i]);
}
return k >= razmqna;
}
void read()
{
cin >> n >> m;
int minch = 1e9;
for(int i = 1; i <= n; i++)
{
cin >> w[i];
minch = min(minch,w[i]);
}
for(int i = 2; i <= n; i++)
{
pref[i] = pref[i-1];
if(w[i-1]<=w[i]) pref[i]++;
}
int l,r,k;
for(int i = 1; i <= m; i++)
{
cin >> l >> r >> k;
if(minch>k)
{
if(pref[r]-pref[l] == r-l) cout << 1 << endl;
else cout << 0 << endl;
}
else
{
if(check(l,r,k)) cout << 1 << endl;
else cout << 0 << endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
read();
return 0;
}
# | 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... |