답안 #256836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256836 2020-08-03T09:27:15 Z AM1648 Gap (APIO16_gap) C++17
100 / 100
61 ms 1916 KB
/* be name khoda */
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)

#define F first
#define S second

// ------------------------------------------------------------------

const ll maxn = 100010;
const ll maxa = 1000000000000000000;

ll A[maxn];

long long findGap(int T, int N) {
    if (T == 1) {
        A[0] = -1;
        A[N + 1] = maxa + 1;
        for (ll i = 0, j = N + 1; j - i > 1; ++i, --j) {
            MinMax(A[i] + 1, A[j] - 1, A + i + 1, A + j - 1);
        }
        ll ans = 0;
        forifrom (i, 1, N) ans = max(ans, A[i + 1] - A[i]);
        return ans;
    } else {
        ll lt, rt;
        MinMax(0, maxa, &lt, &rt);
        ll d = (rt - lt + N - 2) / (N - 1);
        ll i = lt, j = lt;
        while (j + 1 <= rt - 1) {
            ll a, b; MinMax(j + 1, min(j + d, rt - 1), &a, &b);
            if (a != -1) {
                d = max(d, a - i);
                i = j = b;
            } else {
                j += d;
            }
        }
        d = max(d, rt - i);
        return d;
    }
}
# 결과 실행 시간 메모리 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 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 0 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 14 ms 700 KB Output is correct
18 Correct 12 ms 768 KB Output is correct
19 Correct 13 ms 768 KB Output is correct
20 Correct 11 ms 768 KB Output is correct
21 Correct 51 ms 1912 KB Output is correct
22 Correct 61 ms 1912 KB Output is correct
23 Correct 59 ms 1912 KB Output is correct
24 Correct 51 ms 1912 KB Output is correct
25 Correct 44 ms 1916 KB Output is correct
26 Correct 55 ms 1912 KB Output is correct
27 Correct 55 ms 1892 KB Output is correct
28 Correct 57 ms 1876 KB Output is correct
29 Correct 52 ms 1912 KB Output is correct
30 Correct 36 ms 1912 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 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 0 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 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 10 ms 512 KB Output is correct
17 Correct 11 ms 512 KB Output is correct
18 Correct 9 ms 512 KB Output is correct
19 Correct 9 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 36 ms 1144 KB Output is correct
22 Correct 37 ms 1144 KB Output is correct
23 Correct 37 ms 1272 KB Output is correct
24 Correct 45 ms 1144 KB Output is correct
25 Correct 60 ms 1144 KB Output is correct
26 Correct 44 ms 1132 KB Output is correct
27 Correct 39 ms 1144 KB Output is correct
28 Correct 37 ms 1056 KB Output is correct
29 Correct 36 ms 1144 KB Output is correct
30 Correct 24 ms 1144 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct