#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PUT(a, b) freopen(a, "r", stdin); freopen(b, "w", stdout);
#define all(a) a.begin(), a.end()
#define answerNO {cout << "NO" << endl; return;}
#define answerYES {cout << "YES" << endl; return;}
using namespace std;
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
ll mod = 1e9+7;
struct SEGTREE{
ll n;
VL tree;
void upd(ll N, ll L, ll R, ll i, ll s){
if(i < L || i > R)return;
if(L == R){
tree[N] = s;
return;
}
ll M = (L + R) / 2;
upd(2 * N + 1, L, M, i, s);
upd(2 * N + 2, M + 1, R, i, s);
tree[N] = max(tree[2 * N + 1], tree[2 * N + 2]);
}
ll get(ll N, ll L, ll R, ll l, ll r){
if(R < l || L > r){
return 0;
}
if(L >= l && R <= r){
return tree[N];
}
ll M = (L + R) / 2;
return max(get(2 * N + 1, L, M, l, r), get(2 * N + 2, M + 1, R, l, r));
}
SEGTREE(ll sz){
n = 1;
while(n < sz)n *= 2;
tree = VL(2 * n, 0);
}
ll get(ll l, ll r){
return get(0, 0, n - 1, l, r);
}
void upd(ll i, ll s){
upd(0, 0, n - 1, i, s);
}
};
void solve(){
ll n, m; cin >> n >> m;
VL a(n);
rep(i, n){
cin >> a[i];
}
SEGTREE seg(n);
sort(all(a));
rep(i, n){
seg.upd(i, a[i]);
}
rep(i, m){
ll l, r, k; cin >> l >> r >> k;
--l, --r;
ll sum = seg.get(l, r);
if(sum <= k){
cout << "1\n";
}
else{
cout << "0\n";
}
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
//PUT(".in", ".out");
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
764 ms |
58472 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
56 ms |
5460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
460 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |