제출 #1302747

#제출 시각아이디문제언어결과실행 시간메모리
1302747chithanhnguyenHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
34 / 100
3093 ms10220 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define pii pair<int, int>
#define fi first
#define se second
#define __builtin_popcount __builtin_popcountll
#define all(x) (x).begin(), (x).end()
#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(x) ((1ll << (x)))

#define debug(a, l, r) for (int _i = (l); _i <= (r); ++_i) cout << (a)[_i] << ' '; cout << '\n';

const int MAXN = 1e6 + 6;
int n, m, w[MAXN];

signed main() {
    #ifdef NCTHANH
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> w[i];

    while (m--) {
        int l, r, k; cin >> l >> r >> k;
        bool flag = 1;
        int premx = 0;
        for (int i = l; i <= r; ++i) {
            if (premx > w[i] && premx + w[i] > k) {
                flag = 0;
            }

            premx = max(premx, w[i]);
            if (!flag) break;
        }

        cout << flag << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...