Submission #1040410

# Submission time Handle Problem Language Result Execution time Memory
1040410 2024-08-01T03:38:47 Z Neco_arc Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
17 / 100
3000 ms 6732 KB
#include <bits/stdc++.h>
#ifdef LOCAL
#include <bits/debug.hpp>
#endif // LOCAL

#define ll long long
#define all(x) x.begin(), x.end()
#define Neco "Hedgehog Daniyar and Algorithms"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 2e5 + 7

using namespace std;

const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;

int n, q;
struct QUERY { int l, r, k; } qr[maxn];
int a[maxn];

namespace TRAU {

    int calc(int l, int r) {
        int Max = -1e9, ans = 0;
        fi(i, l, r) {
            if(a[i] < Max) ans = max(ans, a[i] + Max);
            Max = max(Max, a[i]);
        }
        return ans;
    }

    void solve() {
        fi(i, 1, q) {
            int l = qr[i].l, r = qr[i].r, k = qr[i].k;
            cout << (calc(l, r) <= k) << '\n';
        }
    }
}

void solve()
{

    cin >> n >> q;
    fi(i, 1, n) cin >> a[i];
    fi(i, 1, q) cin >> qr[i].l >> qr[i].r >> qr[i].k;

    TRAU::solve();


}


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if(fopen(Neco".inp", "r")) {
        freopen(Neco".inp", "r", stdin);
        freopen(Neco".out", "w", stdout);
    }


    int nTest = 1;
//    cin >> nTest;


    while(nTest--)
    {
        solve();
    }


    return 0;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen(Neco".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(Neco".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 3 ms 2536 KB Output is correct
13 Correct 5 ms 2396 KB Output is correct
14 Correct 6 ms 2396 KB Output is correct
15 Correct 6 ms 2540 KB Output is correct
16 Correct 10 ms 2536 KB Output is correct
17 Correct 8 ms 2396 KB Output is correct
18 Correct 10 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 6732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1393 ms 2652 KB Output is correct
2 Execution timed out 3049 ms 2904 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 3 ms 2536 KB Output is correct
13 Correct 5 ms 2396 KB Output is correct
14 Correct 6 ms 2396 KB Output is correct
15 Correct 6 ms 2540 KB Output is correct
16 Correct 10 ms 2536 KB Output is correct
17 Correct 8 ms 2396 KB Output is correct
18 Correct 10 ms 2396 KB Output is correct
19 Execution timed out 3073 ms 3576 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 3 ms 2536 KB Output is correct
13 Correct 5 ms 2396 KB Output is correct
14 Correct 6 ms 2396 KB Output is correct
15 Correct 6 ms 2540 KB Output is correct
16 Correct 10 ms 2536 KB Output is correct
17 Correct 8 ms 2396 KB Output is correct
18 Correct 10 ms 2396 KB Output is correct
19 Runtime error 47 ms 6732 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -