답안 #976451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976451 2024-05-06T15:00:38 Z biank Gap (APIO16_gap) C++14
30 / 100
52 ms 3880 KB
#include <bits/stdc++.h>
#include "gap.h"

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)

const ll MAX_A = 1e18;

ll ceilDiv(ll a, ll b) {
    return (a + b - 1) / b;
}

ll findGap(int T, int N) {
    if (T == 1) {
        ll mini = -1LL, maxi = MAX_A + 1LL;
        vector<ll> a(N);
        int l = 0, r = N - 1;
        while (l <= r) {
            MinMax(mini + 1, maxi - 1, &mini, &maxi);
            a[l++] = mini, a[r--] = maxi;
        }
        ll maxGap = 0LL;
        for (int i = 1; i < N; i++) {
            maxGap = max(maxGap, a[i] - a[i - 1]);
        }
        return maxGap;
    } else {
        ll mini = 0LL, maxi = MAX_A;
        MinMax(mini, maxi, &mini, &maxi);
        ll minRes = ceilDiv(maxi - mini + 1LL, N - 1);
        ll prevMax = mini, maxGap = 0LL;
        for (ll i = mini; i <= maxi; i += minRes) {
            ll minInRange, maxInRange;
            MinMax(i, i + minRes - 1LL, &minInRange, &maxInRange);
            if (minInRange != -1) {
                maxGap = max(maxGap, minInRange - prevMax);
                prevMax = maxInRange;
            }
        }
        return maxGap;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2512 KB Output is correct
16 Correct 8 ms 2584 KB Output is correct
17 Correct 8 ms 2576 KB Output is correct
18 Correct 9 ms 2584 KB Output is correct
19 Correct 9 ms 2772 KB Output is correct
20 Correct 7 ms 2572 KB Output is correct
21 Correct 39 ms 3572 KB Output is correct
22 Correct 30 ms 3624 KB Output is correct
23 Correct 30 ms 3624 KB Output is correct
24 Correct 32 ms 3624 KB Output is correct
25 Correct 28 ms 3616 KB Output is correct
26 Correct 35 ms 3624 KB Output is correct
27 Correct 30 ms 3624 KB Output is correct
28 Correct 31 ms 3620 KB Output is correct
29 Correct 33 ms 3880 KB Output is correct
30 Correct 29 ms 3624 KB Output is correct
31 Correct 1 ms 2644 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 2 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 10 ms 2592 KB Output is correct
17 Correct 13 ms 2584 KB Output is correct
18 Correct 10 ms 2656 KB Output is correct
19 Correct 11 ms 2540 KB Output is correct
20 Correct 6 ms 2568 KB Output is correct
21 Correct 41 ms 2904 KB Output is correct
22 Correct 50 ms 3008 KB Output is correct
23 Correct 41 ms 2856 KB Output is correct
24 Correct 48 ms 2840 KB Output is correct
25 Correct 52 ms 2832 KB Output is correct
26 Correct 42 ms 2856 KB Output is correct
27 Correct 45 ms 2864 KB Output is correct
28 Correct 45 ms 2856 KB Output is correct
29 Correct 42 ms 2856 KB Output is correct
30 Correct 34 ms 2848 KB Output is correct
31 Correct 1 ms 2388 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct