답안 #96248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96248 2019-02-07T12:52:53 Z xplus2g4 Gap (APIO16_gap) C++11
100 / 100
86 ms 2680 KB
#include "gap.h"
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
typedef long long ll;
ll a[MAX_N*2];
long long findGap(int T, int N)
{
    ll ans = 1, s = 0, t = 1e18, mn, mx;
    int n = 0;
    if (T == 1) {
        ll head = 0, tail = N-1;
        while (head <= tail) {
            MinMax(s, t, &mn, &mx);
            a[head++] = mn;
            a[tail--] = mx;
            s = mn+1;
            t = mx-1;
        }
        n = N;
    } else {
        MinMax(s, t, &mn, &mx);
        ll d = (mx-mn+N-1)/N, x, y;
        a[n++] = mn;
        for (s = mn+1, t = s+d; s < mx; s = t+1, t = s+d) {
            MinMax(s, min(t, mx-1), &x, &y);
            if (x == -1)
                continue;
            a[n++] = x;
            a[n++] = y;
        }
        a[n++] = mx;
    }
    for (int i = 1; i < n; ++i)
        ans = max(ans, a[i] - a[i-1]);

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 13 ms 764 KB Output is correct
17 Correct 13 ms 760 KB Output is correct
18 Correct 17 ms 760 KB Output is correct
19 Correct 12 ms 760 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 50 ms 1912 KB Output is correct
22 Correct 47 ms 1912 KB Output is correct
23 Correct 50 ms 1884 KB Output is correct
24 Correct 51 ms 1912 KB Output is correct
25 Correct 45 ms 1912 KB Output is correct
26 Correct 47 ms 1912 KB Output is correct
27 Correct 48 ms 1912 KB Output is correct
28 Correct 65 ms 1884 KB Output is correct
29 Correct 49 ms 1912 KB Output is correct
30 Correct 46 ms 1912 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 760 KB Output is correct
17 Correct 17 ms 760 KB Output is correct
18 Correct 17 ms 760 KB Output is correct
19 Correct 18 ms 752 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 67 ms 2168 KB Output is correct
22 Correct 76 ms 2168 KB Output is correct
23 Correct 82 ms 2168 KB Output is correct
24 Correct 75 ms 2144 KB Output is correct
25 Correct 67 ms 2680 KB Output is correct
26 Correct 65 ms 2040 KB Output is correct
27 Correct 86 ms 2168 KB Output is correct
28 Correct 66 ms 2168 KB Output is correct
29 Correct 81 ms 2072 KB Output is correct
30 Correct 37 ms 1272 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct