Submission #1061644

# Submission time Handle Problem Language Result Execution time Memory
1061644 2024-08-16T11:24:34 Z VMaksimoski008 Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
30 / 100
298 ms 32848 KB
#include <bits/stdc++.h>
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n, q;
    cin >> n >> q;

    vector<int> v(n+1);
    for(int i=1; i<=n; i++) cin >> v[i];

    if(n <= 5000 && q <= 5000) {
        while(q--) {
            int l, r, k;
            cin >> l >> r >> k;
            bool ok = 1;
            int mx = v[l];
            for(int i=l+1; i<=r&&ok; i++) {
                if(mx > v[i] && mx + v[i] > k) ok = 0;
                mx = max(mx, v[i]);
            }
            cout << ok << '\n';
        }
        return 0;
    }

    vector<int> pref(n+1);
    for(int i=1; i+1<=n; i++) pref[i] = (v[i] <= v[i+1]);
    for(int i=2; i<=n; i++) pref[i] += pref[i-1];

    while(q--) {
        int l, r, k;
        cin >> l >> r >> k;
        if(l == r) {
            cout << 1 << '\n';
            continue;
        }

        if(pref[r-1] - pref[l-1] == r - l) cout << 1 << '\n';
        else cout << 0 << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 10260 KB Output is correct
2 Correct 298 ms 10152 KB Output is correct
3 Correct 283 ms 10072 KB Output is correct
4 Correct 292 ms 10172 KB Output is correct
5 Correct 291 ms 32848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Incorrect 57 ms 2272 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 9 ms 348 KB Output is correct
19 Correct 277 ms 10260 KB Output is correct
20 Correct 298 ms 10152 KB Output is correct
21 Correct 283 ms 10072 KB Output is correct
22 Correct 292 ms 10172 KB Output is correct
23 Correct 291 ms 32848 KB Output is correct
24 Incorrect 23 ms 1372 KB Output isn't correct
25 Halted 0 ms 0 KB -