Submission #272674

# Submission time Handle Problem Language Result Execution time Memory
272674 2020-08-18T13:23:35 Z toonewbie Gap (APIO16_gap) C++17
100 / 100
79 ms 2040 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
#define ll long long

ll A[100005];
ll findGap(int T, int N) {
    if (T == 1) {
        ll a = 0, b = 1e18;
        int l = 0, r = N - 1;
        while(l <= r) {
            MinMax(a, b, &a, &b);
            A[l++] = a++; A[r--] = b--;
        }
        a = 0;
        for (int i = 1; i < N; i++) a = max(a, A[i] - A[i - 1]);
        return a;
    } else {
        ll a, b, res = 0;
        MinMax(0, 1e18, &a, &b);
        if (b - a + 1 == N) return 1;
        ll sz = (b - (a + 1)) / (N - 1);
        /// [a + 1, a + sz + 1], [a + sz + 2, a + ]
        ll last = a, X, Y;
        for (ll x = a + 1; x <= b - 1; x += sz + 1) {
            /// [x, x + sz]
            MinMax(x, x + sz, &X, &Y);
            if (X != -1) res = max(res, X - last);
            if (Y != -1) last = Y;
        }
        return max(res, b - last);
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 13 ms 768 KB Output is correct
17 Correct 13 ms 768 KB Output is correct
18 Correct 13 ms 768 KB Output is correct
19 Correct 14 ms 768 KB Output is correct
20 Correct 11 ms 896 KB Output is correct
21 Correct 51 ms 1912 KB Output is correct
22 Correct 59 ms 1844 KB Output is correct
23 Correct 51 ms 1912 KB Output is correct
24 Correct 54 ms 1912 KB Output is correct
25 Correct 45 ms 1904 KB Output is correct
26 Correct 52 ms 1916 KB Output is correct
27 Correct 54 ms 1880 KB Output is correct
28 Correct 55 ms 1896 KB Output is correct
29 Correct 52 ms 1912 KB Output is correct
30 Correct 42 ms 2040 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 640 KB Output is correct
17 Correct 20 ms 512 KB Output is correct
18 Correct 17 ms 640 KB Output is correct
19 Correct 19 ms 512 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 69 ms 1144 KB Output is correct
22 Correct 75 ms 1148 KB Output is correct
23 Correct 76 ms 1144 KB Output is correct
24 Correct 79 ms 1144 KB Output is correct
25 Correct 60 ms 1144 KB Output is correct
26 Correct 68 ms 1096 KB Output is correct
27 Correct 69 ms 1144 KB Output is correct
28 Correct 68 ms 1144 KB Output is correct
29 Correct 69 ms 1048 KB Output is correct
30 Correct 35 ms 1152 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct