답안 #567643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
567643 2022-05-23T22:21:00 Z four_specks Gap (APIO16_gap) C++17
100 / 100
59 ms 1876 KB
#include "gap.h"

#include <bits/stdc++.h>

using namespace std;

long long findGap(int T, int N)
{
    if (T == 1)
    {
        vector<long long> a(N);
        long long mn = 0, mx = LLONG_MAX;
        for (int l = 0, r = N - 1; l <= r; l++, r--)
        {
            MinMax(mn, mx, &mn, &mx);
            a[l] = mn, a[r] = mx;
            mn += 1, mx -= 1;
        }

        long long gap = 0;
        for (int i = 0; i < N - 1; i++)
            gap = max(gap, a[i + 1] - a[i]);

        return gap;
    }
    else if (T == 2)
    {
        long long l = 0, r = LLONG_MAX;
        MinMax(l, r, &l, &r);

        long long block = (r - l + 1) / (N - 1);

        long long gap = 0;

        long long x = l;
        for (l += 1; l <= r; l += block + 1)
        {
            long long mn, mx;
            MinMax(l, l + block, &mn, &mx);
            if (mn != -1)
            {
                gap = max(gap, mn - x);
                x = mx;
            }
        }

        return gap;
    }
    else
        assert(0);

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 644 KB Output is correct
17 Correct 9 ms 632 KB Output is correct
18 Correct 9 ms 636 KB Output is correct
19 Correct 9 ms 724 KB Output is correct
20 Correct 7 ms 720 KB Output is correct
21 Correct 37 ms 1824 KB Output is correct
22 Correct 44 ms 1824 KB Output is correct
23 Correct 42 ms 1824 KB Output is correct
24 Correct 41 ms 1772 KB Output is correct
25 Correct 38 ms 1876 KB Output is correct
26 Correct 37 ms 1868 KB Output is correct
27 Correct 37 ms 1828 KB Output is correct
28 Correct 37 ms 1836 KB Output is correct
29 Correct 36 ms 1816 KB Output is correct
30 Correct 29 ms 1860 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 2 ms 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 452 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 13 ms 464 KB Output is correct
17 Correct 12 ms 464 KB Output is correct
18 Correct 15 ms 464 KB Output is correct
19 Correct 11 ms 464 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 50 ms 1036 KB Output is correct
22 Correct 50 ms 1056 KB Output is correct
23 Correct 59 ms 1024 KB Output is correct
24 Correct 56 ms 1080 KB Output is correct
25 Correct 46 ms 1064 KB Output is correct
26 Correct 52 ms 968 KB Output is correct
27 Correct 51 ms 1080 KB Output is correct
28 Correct 51 ms 976 KB Output is correct
29 Correct 53 ms 968 KB Output is correct
30 Correct 28 ms 1052 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct