답안 #48387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48387 2018-05-12T13:30:15 Z BThero Gap (APIO16_gap) C++17
70 / 100
83 ms 2968 KB
// Why am I so stupid? :c
#include <bits/stdc++.h>
#include "gap.h"

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

typedef long long ll;

using namespace std;

long long findGap(int t, int n) {
    ll arr[n * 2 + 5], que[2], ret = 0;
    int sz = 0;

    if (n <= 5) {
        arr[0] = 0, arr[n + 1] = (ll)1e18 + 1;
        int l = 1, r = n;

        while (l <= r) {
            MinMax(arr[l - 1] + 1, arr[r + 1] - 1, arr + l, arr + r);
            ++l, --r;
        }

        for (int i = 1; i < n; ++i) {
            ret = max(ret, arr[i + 1] - arr[i]);
        }
    }
    else {
        MinMax(1, (ll)1e18, que, que + 1);
        ll l = que[0], r = que[1];

        arr[++sz] = l++;
        arr[++sz] = r--;

        ll a = (r - l + 1) / (n - 1);
        ll b = (r - l + 1) % (n - 1);
        ll cur = l;

        for (int i = 1; i < n; ++i) {
            ll len = a;

            if (b > 0) {
                ++len, --b;
            }

            MinMax(cur, cur + len - 1, que, que + 1);

            if (que[0] != -1) {
                arr[++sz] = que[0];
                arr[++sz] = que[1];
            }

            cur += len;
        }

        sort(arr + 1, arr + sz + 1);
        sz = unique(arr + 1, arr + sz + 1) - arr - 1;

        for (int i = 1; i < sz; ++i) {
            ret = max(ret, arr[i + 1] - arr[i]);
        }
    }

    return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 428 KB Output isn't correct
4 Incorrect 2 ms 428 KB Output isn't correct
5 Incorrect 2 ms 480 KB Output isn't correct
6 Incorrect 2 ms 480 KB Output isn't correct
7 Incorrect 2 ms 584 KB Output isn't correct
8 Incorrect 2 ms 584 KB Output isn't correct
9 Incorrect 2 ms 584 KB Output isn't correct
10 Incorrect 2 ms 584 KB Output isn't correct
11 Incorrect 3 ms 584 KB Output isn't correct
12 Incorrect 3 ms 772 KB Output isn't correct
13 Incorrect 3 ms 772 KB Output isn't correct
14 Incorrect 3 ms 772 KB Output isn't correct
15 Incorrect 3 ms 772 KB Output isn't correct
16 Incorrect 20 ms 920 KB Output isn't correct
17 Incorrect 20 ms 996 KB Output isn't correct
18 Incorrect 21 ms 996 KB Output isn't correct
19 Incorrect 21 ms 996 KB Output isn't correct
20 Incorrect 10 ms 996 KB Output isn't correct
21 Incorrect 75 ms 2356 KB Output isn't correct
22 Incorrect 77 ms 2356 KB Output isn't correct
23 Incorrect 75 ms 2356 KB Output isn't correct
24 Incorrect 80 ms 2416 KB Output isn't correct
25 Incorrect 74 ms 2920 KB Output isn't correct
26 Incorrect 77 ms 2920 KB Output isn't correct
27 Incorrect 75 ms 2920 KB Output isn't correct
28 Incorrect 80 ms 2920 KB Output isn't correct
29 Incorrect 83 ms 2920 KB Output isn't correct
30 Incorrect 39 ms 2920 KB Output isn't correct
31 Incorrect 2 ms 2920 KB Output isn't correct
32 Incorrect 2 ms 2920 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2920 KB Output is correct
2 Correct 2 ms 2920 KB Output is correct
3 Correct 2 ms 2920 KB Output is correct
4 Correct 2 ms 2920 KB Output is correct
5 Correct 2 ms 2920 KB Output is correct
6 Correct 2 ms 2920 KB Output is correct
7 Correct 2 ms 2920 KB Output is correct
8 Correct 2 ms 2920 KB Output is correct
9 Correct 2 ms 2920 KB Output is correct
10 Correct 2 ms 2920 KB Output is correct
11 Correct 3 ms 2920 KB Output is correct
12 Correct 3 ms 2920 KB Output is correct
13 Correct 2 ms 2920 KB Output is correct
14 Correct 3 ms 2920 KB Output is correct
15 Correct 3 ms 2920 KB Output is correct
16 Correct 23 ms 2920 KB Output is correct
17 Correct 19 ms 2920 KB Output is correct
18 Correct 21 ms 2920 KB Output is correct
19 Correct 19 ms 2920 KB Output is correct
20 Correct 9 ms 2920 KB Output is correct
21 Correct 79 ms 2920 KB Output is correct
22 Correct 74 ms 2920 KB Output is correct
23 Correct 77 ms 2920 KB Output is correct
24 Correct 75 ms 2920 KB Output is correct
25 Correct 71 ms 2968 KB Output is correct
26 Correct 75 ms 2968 KB Output is correct
27 Correct 77 ms 2968 KB Output is correct
28 Correct 80 ms 2968 KB Output is correct
29 Correct 76 ms 2968 KB Output is correct
30 Correct 39 ms 2968 KB Output is correct
31 Correct 2 ms 2968 KB Output is correct
32 Correct 2 ms 2968 KB Output is correct