답안 #712717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
712717 2023-03-19T14:21:44 Z hoainiem Gap (APIO16_gap) C++14
100 / 100
61 ms 1900 KB
#include "gap.h"
#include <bits/stdc++.h>
#define nmax 100008
const long long inf = 1e18;
using namespace std;
long long ans = -1, a[nmax];
long long findGap(int T, int n)
{
    if (T == 1){
        a[0] = -1;
        a[n + 1] = inf;
        a[n + 1] += 8;
        for (int i = 1, j = n; i <= j; i++, j--){
            if (i < j)
                MinMax(a[i - 1] + 1, a[j + 1] - 1, &a[i], &a[j]);
            else
                MinMax(a[i - 1] + 1, a[j + 1] - 1, &a[i], &a[n + 2]);
        }

        for (int i = 1; i < n; i++)
            ans = max(ans, a[i + 1] - a[i]);
    }
    else{
        long long u, v, blk, x, y, pre;
        MinMax(0, inf + 8, &u, &v);
        blk = (v - u) / (n - 1) + 1;
        pre = u;
        if (n == 2)
            return v - u;
        for (long long l = u + 1, r = u + 1 + blk; l < v; l += blk, r += blk){
            if (r >= v)
                r = v;
            if (l >= r)
                break;
            MinMax(l, r - 1, &x, &y);
            if (x == -1 && y == -1)
                continue;
            ans = max(ans, x - pre);
            pre = y;
        }
        ans = max(ans, v - pre);
    }
	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 1 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 1 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 9 ms 688 KB Output is correct
17 Correct 10 ms 716 KB Output is correct
18 Correct 9 ms 688 KB Output is correct
19 Correct 10 ms 592 KB Output is correct
20 Correct 8 ms 592 KB Output is correct
21 Correct 36 ms 1784 KB Output is correct
22 Correct 38 ms 1864 KB Output is correct
23 Correct 41 ms 1784 KB Output is correct
24 Correct 40 ms 1812 KB Output is correct
25 Correct 32 ms 1792 KB Output is correct
26 Correct 36 ms 1744 KB Output is correct
27 Correct 38 ms 1828 KB Output is correct
28 Correct 38 ms 1832 KB Output is correct
29 Correct 40 ms 1900 KB Output is correct
30 Correct 29 ms 1780 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 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 1 ms 300 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 448 KB Output is correct
17 Correct 12 ms 504 KB Output is correct
18 Correct 12 ms 464 KB Output is correct
19 Correct 12 ms 436 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 51 ms 1008 KB Output is correct
22 Correct 50 ms 1084 KB Output is correct
23 Correct 52 ms 960 KB Output is correct
24 Correct 58 ms 1088 KB Output is correct
25 Correct 51 ms 976 KB Output is correct
26 Correct 54 ms 1080 KB Output is correct
27 Correct 56 ms 1064 KB Output is correct
28 Correct 53 ms 1060 KB Output is correct
29 Correct 61 ms 1088 KB Output is correct
30 Correct 34 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct