Submission #842301

# Submission time Handle Problem Language Result Execution time Memory
842301 2023-09-02T18:12:06 Z popovicirobert Gap (APIO16_gap) C++14
56.3068 / 100
46 ms 3116 KB
#include <bits/stdc++.h>

#define lsb(x) (x & (-x))

using ull = unsigned long long;
using ll = long long;

using namespace std;

constexpr ll INF =  1e18;

vector<ll> arr;

#ifdef HOME

void MinMax(ll a, ll b, ll* mn, ll* mx) {
    *mn = INF;
    *mx = -INF;
    for (auto itr : arr) {
        if (itr >= a && itr <= b) {
            *mn = min(*mn, itr);
            *mx = max(*mx, itr);
        }
    }
    if (*mn == INF) {
        *mn = -1;
    }
    if (*mx == -INF) {
        *mx = -1;
    }
}

#else
#include "gap.h"
#endif

pair<ll, ll> Query(ll a, ll b) {
    ll mn, mx;
    MinMax(a, b, &mn, &mx);
    return {mn, mx};
}

ll findGap(int T, int N) {
    pair<ll, ll> res = Query(0, INF);
    
    ll a1 = res.first;
    ll an = res.second;
    ll step = (an - a1 + N - 2) / (N - 1);

    ll answer = 0;

    ll curr = a1;
    while (curr < an) {
        int x = 0;
        do {
            x++;
            res = Query(curr + 1, curr + step * x);
            if (res.second != -1) {
                break;
            }
        } while (true);

        answer = max(answer, res.first - curr);
        curr = res.second;
    }

    return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 0 ms 2392 KB Output isn't correct
3 Incorrect 1 ms 2392 KB Output isn't correct
4 Incorrect 0 ms 2392 KB Output isn't correct
5 Incorrect 1 ms 2392 KB Output isn't correct
6 Incorrect 0 ms 2392 KB Output isn't correct
7 Incorrect 0 ms 2392 KB Output isn't correct
8 Incorrect 0 ms 2392 KB Output isn't correct
9 Incorrect 0 ms 2392 KB Output isn't correct
10 Incorrect 0 ms 2392 KB Output isn't correct
11 Incorrect 1 ms 2392 KB Output isn't correct
12 Incorrect 1 ms 2648 KB Output isn't correct
13 Incorrect 1 ms 2392 KB Output isn't correct
14 Incorrect 1 ms 2392 KB Output isn't correct
15 Incorrect 1 ms 2392 KB Output isn't correct
16 Incorrect 10 ms 2584 KB Output isn't correct
17 Incorrect 11 ms 2584 KB Output isn't correct
18 Incorrect 11 ms 2588 KB Output isn't correct
19 Incorrect 11 ms 2584 KB Output isn't correct
20 Incorrect 5 ms 2572 KB Output isn't correct
21 Incorrect 43 ms 2852 KB Output isn't correct
22 Incorrect 42 ms 2860 KB Output isn't correct
23 Incorrect 42 ms 2856 KB Output isn't correct
24 Incorrect 45 ms 2860 KB Output isn't correct
25 Incorrect 38 ms 2856 KB Output isn't correct
26 Incorrect 43 ms 3116 KB Output isn't correct
27 Incorrect 43 ms 2856 KB Output isn't correct
28 Incorrect 43 ms 2860 KB Output isn't correct
29 Incorrect 43 ms 2856 KB Output isn't correct
30 Incorrect 21 ms 2868 KB Output isn't correct
31 Incorrect 0 ms 2392 KB Output isn't correct
32 Incorrect 0 ms 2392 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Partially correct 1 ms 2392 KB Partially correct
3 Partially correct 0 ms 2392 KB Partially correct
4 Partially correct 1 ms 2392 KB Partially correct
5 Correct 1 ms 2392 KB Output is correct
6 Partially correct 1 ms 2392 KB Partially correct
7 Partially correct 1 ms 2392 KB Partially correct
8 Partially correct 1 ms 2392 KB Partially correct
9 Partially correct 1 ms 2392 KB Partially correct
10 Partially correct 1 ms 2392 KB Partially correct
11 Partially correct 1 ms 2392 KB Partially correct
12 Partially correct 1 ms 2644 KB Partially correct
13 Partially correct 1 ms 2392 KB Partially correct
14 Partially correct 1 ms 2392 KB Partially correct
15 Correct 1 ms 2392 KB Output is correct
16 Partially correct 11 ms 2580 KB Partially correct
17 Partially correct 10 ms 2584 KB Partially correct
18 Partially correct 11 ms 2588 KB Partially correct
19 Partially correct 10 ms 2584 KB Partially correct
20 Correct 5 ms 2572 KB Output is correct
21 Partially correct 45 ms 3008 KB Partially correct
22 Partially correct 42 ms 2852 KB Partially correct
23 Partially correct 43 ms 2864 KB Partially correct
24 Partially correct 46 ms 2840 KB Partially correct
25 Correct 36 ms 2848 KB Output is correct
26 Partially correct 43 ms 2860 KB Partially correct
27 Partially correct 42 ms 2856 KB Partially correct
28 Partially correct 44 ms 2860 KB Partially correct
29 Partially correct 42 ms 2860 KB Partially correct
30 Correct 21 ms 2848 KB Output is correct
31 Partially correct 1 ms 2392 KB Partially correct
32 Partially correct 0 ms 2392 KB Partially correct