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;
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0), cin.tie(0);
#define fs first
#define ss second
#define print(a) \
for (auto x : a) \
cout << x << ' '; \
cout << endl;
#define printmp(a) \
for (auto x : a) \
cout << x.fs << ' ' << x.ss << endl;
void solve()
{
int n, q;
cin >> n >> q;
vector<int> a(n);
for(int i = 0; i < n; i ++)
cin >> a[i];
while(q --){
int l, r, k;
cin >> l >> r >> k;
bool flag = 1;
l --;
r --;
for(int i = l; i <= r; i ++){
for(int j = i - 1; j >= l; j --){
if(a[i] < a[j] and a[i] + a[j] > k){
flag = false;
break;
}
}
if(!flag)
break;
}
if(flag)
cout << 1 << endl;
else
cout << 0 << endl;
}
}
signed main()
{
fastio
int t = 1;
// cin >> t;
while (t--)
{
solve();
cout << endl;
}
}
# | 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... |