Submission #497390

# Submission time Handle Problem Language Result Execution time Memory
497390 2021-12-23T04:15:14 Z kingline Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 20904 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int M = 5005;
const int mod = 1e9 + 7;

int n, m, w[N];
/*
pair < int, int > t[N * 4];

void build(int v, int l, int r) {
    if(l == r) {
        t[v] = {a[l], l};
        return;
    }
    int md = (l + r) / 2;
    build(v * 2, l, md);
    build(v * 2 + 1, md + 1, r);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int get(int v, int l, int r, int tl, int tr) {
    if(l > r) return 0
    if(tl <= l && r <= tr) {
        return t[v];
    }
    if(r < tl || tr < l) return 0;
    int md = (l + r) / 2;
    return max(get(v * 2, l, md, tl, tr),
                   get(v * 2 + 1, md + 1, r, tl, tr));
}*/

main() {
    //file("pieaters");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> w[i];
    }
    //build(1, 1, n);
    for(int i = 1; i <= m; i++) {
        int l, r, k;
        cin >> l >> r >> k;
        bool ok = 1;
        int mx = 0;
        for(int j = l; j <= r; j++) {
            if(mx + w[j] > k && mx > w[j]) {
                ok = 0;
                break;
            }
            mx = max(mx, w[j]);
        }
        cout << ok << endl;
    }
}





Compilation message

sortbooks.cpp:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 268 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 440 KB Output is correct
14 Correct 3 ms 460 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 15 ms 460 KB Output is correct
17 Correct 14 ms 452 KB Output is correct
18 Correct 12 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 538 ms 15816 KB Output is correct
2 Correct 552 ms 20904 KB Output is correct
3 Correct 476 ms 20880 KB Output is correct
4 Correct 509 ms 20904 KB Output is correct
5 Execution timed out 3093 ms 18144 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 603 ms 2636 KB Output is correct
2 Correct 1976 ms 3292 KB Output is correct
3 Execution timed out 3055 ms 2748 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 268 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 440 KB Output is correct
14 Correct 3 ms 460 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 15 ms 460 KB Output is correct
17 Correct 14 ms 452 KB Output is correct
18 Correct 12 ms 452 KB Output is correct
19 Correct 2316 ms 8072 KB Output is correct
20 Correct 2302 ms 8936 KB Output is correct
21 Execution timed out 3021 ms 5712 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 268 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 440 KB Output is correct
14 Correct 3 ms 460 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 15 ms 460 KB Output is correct
17 Correct 14 ms 452 KB Output is correct
18 Correct 12 ms 452 KB Output is correct
19 Correct 538 ms 15816 KB Output is correct
20 Correct 552 ms 20904 KB Output is correct
21 Correct 476 ms 20880 KB Output is correct
22 Correct 509 ms 20904 KB Output is correct
23 Execution timed out 3093 ms 18144 KB Time limit exceeded