답안 #976455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976455 2024-05-06T15:03:12 Z biank Gap (APIO16_gap) C++14
83.5083 / 100
42 ms 3624 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, 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 0 ms 344 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 2392 KB Output is correct
16 Correct 8 ms 2584 KB Output is correct
17 Correct 8 ms 2576 KB Output is correct
18 Correct 8 ms 2828 KB Output is correct
19 Correct 8 ms 2904 KB Output is correct
20 Correct 7 ms 2648 KB Output is correct
21 Correct 30 ms 3624 KB Output is correct
22 Correct 29 ms 3620 KB Output is correct
23 Correct 29 ms 3624 KB Output is correct
24 Correct 30 ms 3624 KB Output is correct
25 Correct 27 ms 3620 KB Output is correct
26 Correct 30 ms 3620 KB Output is correct
27 Correct 30 ms 3620 KB Output is correct
28 Correct 30 ms 3624 KB Output is correct
29 Correct 29 ms 3624 KB Output is correct
30 Correct 27 ms 3592 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 0 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 2392 KB Partially 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 Partially correct 1 ms 2392 KB Partially correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 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 Partially correct 1 ms 2392 KB Partially correct
16 Correct 12 ms 2588 KB Output is correct
17 Correct 11 ms 2680 KB Output is correct
18 Correct 10 ms 2588 KB Output is correct
19 Correct 11 ms 2584 KB Output is correct
20 Correct 6 ms 2572 KB Output is correct
21 Correct 41 ms 2860 KB Output is correct
22 Correct 41 ms 2860 KB Output is correct
23 Correct 41 ms 3108 KB Output is correct
24 Correct 42 ms 2640 KB Output is correct
25 Partially correct 40 ms 2848 KB Partially correct
26 Correct 41 ms 2856 KB Output is correct
27 Correct 42 ms 2680 KB Output is correct
28 Correct 42 ms 2856 KB Output is correct
29 Correct 42 ms 2860 KB Output is correct
30 Correct 25 ms 2848 KB Output is correct
31 Partially correct 1 ms 2392 KB Partially correct
32 Partially correct 0 ms 2392 KB Partially correct