답안 #436087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436087 2021-06-24T08:17:21 Z Lam_lai_cuoc_doi Gap (APIO16_gap) C++17
100 / 100
68 ms 2624 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

constexpr bool typetest = 0;
constexpr int N = 1e6 + 5;

#include "gap.h"

long long findGap(int t, int n)
{
    if (t == 1)
    {
        vector<ll> a(n);
        ll l = 0, r = 1e18;

        for (int i = 0; i < (n + 1) / 2; ++i)
        {
            MinMax(l, r, &l, &r);
            a[i] = l;
            a[n - 1 - i] = r;
            ++l;
            --r;
        }

        ll ans(0);
        for (int i = 0; i < n - 1; ++i)
            ans = max(ans, a[i + 1] - a[i]);
        return ans;
    }
    else
    {
        ll l = 0, r = 1e18;
        MinMax(l, r, &l, &r);
        vector<ll> a;
        a.reserve(n);

        ll x = l, y = r, q = (r - l - 1) % (n - 1);

        for (int i = 1; i <= n - 1; ++i)
        {
            ll v = (y - x - 1) / (n - 1) + (q > 0);
            --q;

            ++l;
            r = l + v - 1;
            ll e, f;

            MinMax(l, r, &e, &f);

            l = r;

            if (e != -1)
            {
                a.emplace_back(e);
                a.emplace_back(f);
            }
        }

        a.emplace_back(x);
        a.emplace_back(y);

        sort(a.begin(), a.end());

        ll ans(0);
        for (int i = 0; i < (int)a.size() - 1; ++i)
            ans = max(ans, a[i + 1] - a[i]);
        return ans;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 11 ms 712 KB Output is correct
17 Correct 11 ms 592 KB Output is correct
18 Correct 12 ms 712 KB Output is correct
19 Correct 11 ms 712 KB Output is correct
20 Correct 10 ms 584 KB Output is correct
21 Correct 44 ms 1856 KB Output is correct
22 Correct 45 ms 1804 KB Output is correct
23 Correct 43 ms 1860 KB Output is correct
24 Correct 43 ms 1796 KB Output is correct
25 Correct 42 ms 1920 KB Output is correct
26 Correct 44 ms 1824 KB Output is correct
27 Correct 43 ms 1824 KB Output is correct
28 Correct 45 ms 1816 KB Output is correct
29 Correct 47 ms 1824 KB Output is correct
30 Correct 35 ms 1828 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 2 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 18 ms 832 KB Output is correct
17 Correct 18 ms 800 KB Output is correct
18 Correct 16 ms 840 KB Output is correct
19 Correct 16 ms 792 KB Output is correct
20 Correct 8 ms 456 KB Output is correct
21 Correct 64 ms 2584 KB Output is correct
22 Correct 63 ms 2624 KB Output is correct
23 Correct 64 ms 2560 KB Output is correct
24 Correct 68 ms 2560 KB Output is correct
25 Correct 62 ms 2612 KB Output is correct
26 Correct 65 ms 2624 KB Output is correct
27 Correct 65 ms 2584 KB Output is correct
28 Correct 64 ms 2624 KB Output is correct
29 Correct 68 ms 2624 KB Output is correct
30 Correct 36 ms 1144 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct