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 ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
int n,a[maxn],m,b[maxn],c[maxn],d[maxn];
void webbly_abi_spasibo(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= m; i++){
cin >> b[i] >> c[i] >> d[i];
}
if(n <= 5000 && m <= 5000){
for(int i = 1; i <= m; i++){
int l = b[i], r = c[i], val = d[i];
int mx = a[l];
bool ok = 1;
for(int j = l + 1; j <= r; j++){
if(mx > a[j]){
if(mx + a[j] > val) {
ok = 0;
break;
}
}
mx = max(mx, a[j]);
}
cout << ok << '\n';
}
}
}
signed main(){
//
// freopen("greedy.in", "r", stdin);
// freopen("greedy.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
//cin >> tt;
while(tt--){
webbly_abi_spasibo();
}
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... |