| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 947482 | dilanyan | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 76 ms | 4712 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//-------------dilanyan------------\\ 
 
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
 
//------------------KarginDefines--------------------\\ 
 
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
 
 
//-------------------KarginConstants------------------\\ 
 
const ll mod = 1000000007;
const ll inf = 1e18;
 
//-------------------KarginCode------------------------\\ 
 
const int N = 1000005;
int w[N];
int n, m;
void KarginSolve() {
    cin >> n >> m;
    for (int i = 0;i < n;i++) cin >> w[i];
    if (n <= 5000 && m <= 5000) {
        while (m--) {
            int l, r, k;
            cin >> l >> r >> k;
            l--;
            int ans = 1, cur = w[l];
            for (int i = l;i < r - 1;i++) {
                if (cur > w[i + 1]) {
                    if (cur + w[i + 1] > k) {
                        ans = 0;
                        break;
                    }
                }
                else cur = w[i + 1];
            }
            cout << ans << '\n';
        }
    }
}
 
int main() {
    //Usaco
    Kargin;
    int test = 1;
    //cin >> test;
    while (test--) {
        KarginSolve();
    }
    return 0;
}
Compilation message (stderr)
| # | 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... | ||||
