답안 #515645

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515645 2022-01-19T11:40:08 Z Aldas25 Gap (APIO16_gap) C++14
100 / 100
58 ms 1888 KB
#include "gap.h"
#include<bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(i, 1, (n))
#define f first
#define s second
#define pb push_back
typedef long long ll;

const int MAXN = 100100;
const ll INF = 1e18;

ll a[MAXN];

long long findGap(int T, int n)
{
    if (T == 1) {
        int le = 2, ri = n-1;
        //a[0] = -1, a[n+1] = INF;
        MinMax(0, INF, &a[1], &a[n]);

        int m = 0;

        while (le <= ri) {
            MinMax(a[le-1]+1, a[ri+1]-1, &a[le], &a[ri]);
            m++;

            le++;
            ri--;
        }

        ll ans = 0;
        FOR(i, 1, n-1) {
            ans = max(ans, a[i+1] - a[i]);
        }

        return ans;

    } else {
        ll mn, mx;
        MinMax(0, INF, &mn, &mx);

        ll x = (mx-mn + n - 2) / (n - 1);
        x++;
        ll ans = x-1;
        ll lst = mn;
        ll i;
        for (i = mn; i + x < mx; i += x) {
            ll le, ri;
            MinMax(i, min(i + x - 1, mx), &le, &ri);
            if (le != -1) {
                ans = max(ans, le - lst);
                lst = ri;
            }
        }
        ll le,ri;
        MinMax(i, mx, &le, &ri);
        if(le!= -1) ans=max(ans, le-lst);

        return ans;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 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 9 ms 660 KB Output is correct
17 Correct 10 ms 584 KB Output is correct
18 Correct 9 ms 584 KB Output is correct
19 Correct 10 ms 596 KB Output is correct
20 Correct 7 ms 612 KB Output is correct
21 Correct 39 ms 1736 KB Output is correct
22 Correct 35 ms 1856 KB Output is correct
23 Correct 38 ms 1760 KB Output is correct
24 Correct 41 ms 1800 KB Output is correct
25 Correct 33 ms 1844 KB Output is correct
26 Correct 37 ms 1816 KB Output is correct
27 Correct 38 ms 1888 KB Output is correct
28 Correct 47 ms 1808 KB Output is correct
29 Correct 35 ms 1808 KB Output is correct
30 Correct 29 ms 1764 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 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 0 ms 200 KB Output is correct
10 Correct 0 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 536 KB Output is correct
17 Correct 12 ms 512 KB Output is correct
18 Correct 13 ms 512 KB Output is correct
19 Correct 12 ms 516 KB Output is correct
20 Correct 6 ms 456 KB Output is correct
21 Correct 52 ms 1048 KB Output is correct
22 Correct 58 ms 1072 KB Output is correct
23 Correct 49 ms 1052 KB Output is correct
24 Correct 49 ms 1048 KB Output is correct
25 Correct 45 ms 1080 KB Output is correct
26 Correct 56 ms 1044 KB Output is correct
27 Correct 53 ms 1052 KB Output is correct
28 Correct 49 ms 1048 KB Output is correct
29 Correct 49 ms 1080 KB Output is correct
30 Correct 26 ms 1080 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct