Submission #133259

# Submission time Handle Problem Language Result Execution time Memory
133259 2019-07-20T10:12:18 Z mlyean00 Gap (APIO16_gap) C++14
100 / 100
77 ms 1284 KB
#include "gap.h"

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll findGap(int T, int N) {
    ll ans = 0;

    ll mn, mx;
    MinMax(0, 1'000'000'000'000'000'000LL, &mn, &mx);

    if (T == 1) {
        for (int i = 1; i < (N + 1) / 2; ++i) {
            ll mn2, mx2;
            MinMax(mn + 1, mx - 1, &mn2, &mx2);
            ans = max({ans, mn2 - mn, mx - mx2});
            mn = mn2;
            mx = mx2;
        }
        ans = max(ans, mx - mn);
    } else if (T == 2) {
        const ll min_gap = 1 + (mx - mn - 1) / (N - 1);
        ll last = mn;

        for (ll l = mn + 1; l < mx; l += min_gap) {
            ll r = min(mx, l + min_gap) - 1;

            ll mn2, mx2;
            MinMax(l, r, &mn2, &mx2);
            if (mn2 != -1) {
                ans = max(ans, mn2 - last);
                last = mx2;
            }
        }

        ans = max(ans, mx - last);
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 372 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 15 ms 504 KB Output is correct
17 Correct 15 ms 504 KB Output is correct
18 Correct 15 ms 504 KB Output is correct
19 Correct 14 ms 504 KB Output is correct
20 Correct 11 ms 504 KB Output is correct
21 Correct 53 ms 1144 KB Output is correct
22 Correct 54 ms 1284 KB Output is correct
23 Correct 53 ms 1136 KB Output is correct
24 Correct 54 ms 1144 KB Output is correct
25 Correct 46 ms 1144 KB Output is correct
26 Correct 53 ms 1144 KB Output is correct
27 Correct 56 ms 1272 KB Output is correct
28 Correct 53 ms 1144 KB Output is correct
29 Correct 53 ms 1144 KB Output is correct
30 Correct 39 ms 1172 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 19 ms 504 KB Output is correct
17 Correct 20 ms 504 KB Output is correct
18 Correct 20 ms 504 KB Output is correct
19 Correct 19 ms 504 KB Output is correct
20 Correct 10 ms 504 KB Output is correct
21 Correct 72 ms 1064 KB Output is correct
22 Correct 73 ms 1144 KB Output is correct
23 Correct 77 ms 1160 KB Output is correct
24 Correct 73 ms 1144 KB Output is correct
25 Correct 70 ms 1164 KB Output is correct
26 Correct 73 ms 1144 KB Output is correct
27 Correct 71 ms 1144 KB Output is correct
28 Correct 71 ms 1144 KB Output is correct
29 Correct 72 ms 1148 KB Output is correct
30 Correct 37 ms 1144 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct