답안 #557940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557940 2022-05-06T10:22:27 Z Ai7081 Gap (APIO16_gap) C++17
100 / 100
64 ms 7432 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const ll inf = 1e18;

vector<ll> v;

long long findGap(int T, int N)
{
    ll ans = 0;
    if (T==1) {
        v.assign(N, -1);
        ll *mi = new ll, *ma = new ll;
        MinMax((ll)1, inf, mi, ma);
        v[0] = *mi, v[N-1] = *ma;
        for (int i=1; i<=(N-1)/2; i++) {
            MinMax(*mi+1, *ma-1, mi, ma);
            v[i] = *mi, v[N-1-i] = *ma;
        }
        for (int i=0; i<N-1; i++) ans = max(ans, v[i+1] - v[i]);
    }
    else if (T==2) {
        ll *allmin = new ll, *allmax = new ll;
        MinMax((ll)1, inf, allmin, allmax);
        ll gap = (*allmax - *allmin + N-2) / (N-1);
        ll now = *allmin+1, last = *allmin;
        while (now < *allmax) {
            ll *mi = new ll, *ma = new ll;
            MinMax(now, now+gap, mi, ma);
            if (*mi != -1) ans = max(ans, *mi - last);
            if (*ma != -1) last = *ma;
            now = now+gap+1;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 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 1 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 11 ms 688 KB Output is correct
17 Correct 10 ms 592 KB Output is correct
18 Correct 11 ms 672 KB Output is correct
19 Correct 13 ms 684 KB Output is correct
20 Correct 7 ms 592 KB Output is correct
21 Correct 38 ms 1824 KB Output is correct
22 Correct 41 ms 1816 KB Output is correct
23 Correct 41 ms 1864 KB Output is correct
24 Correct 44 ms 1828 KB Output is correct
25 Correct 34 ms 1864 KB Output is correct
26 Correct 47 ms 1820 KB Output is correct
27 Correct 47 ms 1824 KB Output is correct
28 Correct 42 ms 1864 KB Output is correct
29 Correct 45 ms 1828 KB Output is correct
30 Correct 30 ms 1812 KB Output is correct
31 Correct 1 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 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 14 ms 2000 KB Output is correct
17 Correct 15 ms 2000 KB Output is correct
18 Correct 14 ms 1960 KB Output is correct
19 Correct 14 ms 2060 KB Output is correct
20 Correct 10 ms 2000 KB Output is correct
21 Correct 56 ms 7240 KB Output is correct
22 Correct 58 ms 7264 KB Output is correct
23 Correct 59 ms 7432 KB Output is correct
24 Correct 64 ms 7256 KB Output is correct
25 Correct 58 ms 7328 KB Output is correct
26 Correct 63 ms 7240 KB Output is correct
27 Correct 56 ms 7328 KB Output is correct
28 Correct 64 ms 7396 KB Output is correct
29 Correct 57 ms 7256 KB Output is correct
30 Correct 33 ms 6516 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct