답안 #720865

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720865 2023-04-09T15:22:59 Z Joshc Gap (APIO16_gap) C++11
100 / 100
46 ms 2000 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
const ll INF = 1e18;

ll ceildiv(ll a, ll b) {
    return (a+b-1) / b;
}
 
ll findGap(int T, int N) {
    if (T == 1 || N <= 10) {
        vector<ll> a(N);
        int l = 0, r = N-1;
        ll p = -1, q = INF+1;
        while (l <= r) {
            MinMax(p+1, q-1, &p, &q);
            a[l++] = p;
            a[r--] = q;
        }
        ll res = 0;
        for (int i=1; i<N; i++) res = max(res, a[i] - a[i-1]);
        return res;
    } else {
        ll l = 0, big, p, q;
        MinMax(0, INF, &l, &big);
        ll res = ceildiv(big-l, N-1);
        while (l < big) {
            ll sz = res+1;
            bool reachedEnd = false;
            while (true) {
                MinMax(l+1, min(INF, l+sz), &p, &q);
                if (l+sz >= INF && p == -1) {
                    reachedEnd = true;
                    break;
                }
                if (q != -1) break;
                sz *= 2;
            }
            res = max(res, p-l);
            l = q;
            if (reachedEnd) break;
        }
        return res;
    }
}
# 결과 실행 시간 메모리 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 1 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 1 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 324 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 9 ms 636 KB Output is correct
17 Correct 11 ms 676 KB Output is correct
18 Correct 9 ms 592 KB Output is correct
19 Correct 9 ms 648 KB Output is correct
20 Correct 7 ms 592 KB Output is correct
21 Correct 36 ms 1836 KB Output is correct
22 Correct 43 ms 1832 KB Output is correct
23 Correct 45 ms 1844 KB Output is correct
24 Correct 37 ms 1864 KB Output is correct
25 Correct 32 ms 1872 KB Output is correct
26 Correct 37 ms 1764 KB Output is correct
27 Correct 43 ms 1816 KB Output is correct
28 Correct 38 ms 1864 KB Output is correct
29 Correct 37 ms 1812 KB Output is correct
30 Correct 30 ms 2000 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 7 ms 420 KB Output is correct
17 Correct 7 ms 424 KB Output is correct
18 Correct 7 ms 464 KB Output is correct
19 Correct 9 ms 428 KB Output is correct
20 Correct 5 ms 464 KB Output is correct
21 Correct 31 ms 968 KB Output is correct
22 Correct 24 ms 1048 KB Output is correct
23 Correct 25 ms 1060 KB Output is correct
24 Correct 24 ms 1064 KB Output is correct
25 Correct 46 ms 1084 KB Output is correct
26 Correct 30 ms 1060 KB Output is correct
27 Correct 25 ms 1036 KB Output is correct
28 Correct 24 ms 980 KB Output is correct
29 Correct 30 ms 1044 KB Output is correct
30 Correct 13 ms 1104 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct