Submission #501367

# Submission time Handle Problem Language Result Execution time Memory
501367 2022-01-03T00:32:13 Z kevinxiehk Gap (APIO16_gap) C++17
100 / 100
63 ms 1844 KB
#include "gap.h"
// TODO: global variables can be declared here
long long max(long long a, long long b) {
    return (a > b ? a : b);
}
long long findGap(int T, int n) {
    // TODO: implementation
    if(T == 1) {
        long long arr[n + 5];
        for(int i = 0; i < (n + 1) / 2; i++) {
            if(i == 0) MinMax(0, 1000000000000000000LL, &arr[0], &arr[n - 1]);
            else MinMax(arr[i - 1] + 1, arr[n - i] - 1, &arr[i], &arr[n - i - 1]); 
        }
        long long ans = 0;
        for(int i = 0; i < n - 1; i++) ans = max(ans, arr[i + 1] - arr[i]);
        return ans;
    }
    else {
        long long l, r;
        MinMax(0, 1000000000000000000LL, &l, &r);
        long long chunk = (r - l + n - 2) / (n - 1);
        long long a, b, c = l;
        l++;
        long long ans = 0;
        while(l < r) {
            MinMax(l, l + chunk - 1, &a, &b);
            l += chunk;
            if(a == -1) continue;
            ans = max(ans, a - c);
            c = b;
        }
        ans = max(ans, r - c);
        return ans;
    }
}
# Verdict Execution time Memory 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 1 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 200 KB Output is correct
12 Correct 1 ms 252 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 9 ms 652 KB Output is correct
17 Correct 9 ms 648 KB Output is correct
18 Correct 9 ms 628 KB Output is correct
19 Correct 9 ms 636 KB Output is correct
20 Correct 7 ms 664 KB Output is correct
21 Correct 36 ms 1788 KB Output is correct
22 Correct 42 ms 1804 KB Output is correct
23 Correct 37 ms 1800 KB Output is correct
24 Correct 36 ms 1804 KB Output is correct
25 Correct 32 ms 1788 KB Output is correct
26 Correct 43 ms 1804 KB Output is correct
27 Correct 36 ms 1796 KB Output is correct
28 Correct 43 ms 1844 KB Output is correct
29 Correct 37 ms 1808 KB Output is correct
30 Correct 29 ms 1768 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory 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 200 KB Output is correct
12 Correct 1 ms 200 KB Output is correct
13 Correct 1 ms 200 KB Output is correct
14 Correct 1 ms 200 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 13 ms 396 KB Output is correct
17 Correct 13 ms 400 KB Output is correct
18 Correct 12 ms 468 KB Output is correct
19 Correct 13 ms 492 KB Output is correct
20 Correct 6 ms 448 KB Output is correct
21 Correct 50 ms 1024 KB Output is correct
22 Correct 52 ms 1052 KB Output is correct
23 Correct 57 ms 960 KB Output is correct
24 Correct 51 ms 1020 KB Output is correct
25 Correct 45 ms 1032 KB Output is correct
26 Correct 49 ms 1032 KB Output is correct
27 Correct 63 ms 964 KB Output is correct
28 Correct 48 ms 980 KB Output is correct
29 Correct 58 ms 1036 KB Output is correct
30 Correct 30 ms 1052 KB Output is correct
31 Correct 0 ms 272 KB Output is correct
32 Correct 0 ms 200 KB Output is correct