#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
#include "gap.h"
long long a[N];
long long findGap(int T, int n) {
long long mn, mx;
if (T == 1) {
long long l = 0, r = 1e18;
for(int i = 1; i <= (n + 1) / 2; i++) {
MinMax(l, r, &mn, &mx);
a[i] = mn; a[n - i + 1] = mx;
l = mn + 1; r = mx - 1;
}
long long res = 0;
sort(a + 1, a + n + 1);
for(int i = 2; i <= n; i++) res = max(res, a[i] - a[i - 1]);
return res;
}
MinMax(0, 1e18, &mn, &mx);
long long delta = (mx - mn) / (n - 1) + ((mx - mn) % (n - 1) > 0);
long long s = mn + 1, last = mn;
long long res = delta, lmt = mx - 1;
long long a = 1e18, b = 0, c = mn, d = mx;
while (s <= lmt) {
long long t = min(lmt, s + delta);
MinMax(s, t, &mn, &mx);
if (mn != -1) {
a = min(a, mn); b = max(b, mx);
res = max(res, mn - last);
last = mx;
}
s = t + 1;
}
if (a == 1e18) res = max(res, d - c);
else res = max(res, a - c), res = max(res, d - b);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 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 |
1 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 |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
592 KB |
Output is correct |
17 |
Correct |
12 ms |
608 KB |
Output is correct |
18 |
Correct |
13 ms |
592 KB |
Output is correct |
19 |
Correct |
10 ms |
612 KB |
Output is correct |
20 |
Correct |
7 ms |
592 KB |
Output is correct |
21 |
Correct |
45 ms |
1948 KB |
Output is correct |
22 |
Correct |
42 ms |
1832 KB |
Output is correct |
23 |
Correct |
38 ms |
1864 KB |
Output is correct |
24 |
Correct |
41 ms |
1800 KB |
Output is correct |
25 |
Correct |
33 ms |
1840 KB |
Output is correct |
26 |
Correct |
37 ms |
1784 KB |
Output is correct |
27 |
Correct |
42 ms |
1836 KB |
Output is correct |
28 |
Correct |
38 ms |
1832 KB |
Output is correct |
29 |
Correct |
43 ms |
1860 KB |
Output is correct |
30 |
Correct |
30 ms |
1840 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 |
1 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 |
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 |
13 ms |
512 KB |
Output is correct |
17 |
Correct |
12 ms |
520 KB |
Output is correct |
18 |
Correct |
11 ms |
464 KB |
Output is correct |
19 |
Correct |
14 ms |
520 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
52 ms |
1152 KB |
Output is correct |
22 |
Correct |
50 ms |
1084 KB |
Output is correct |
23 |
Correct |
59 ms |
1060 KB |
Output is correct |
24 |
Correct |
48 ms |
1060 KB |
Output is correct |
25 |
Correct |
46 ms |
1060 KB |
Output is correct |
26 |
Correct |
49 ms |
1080 KB |
Output is correct |
27 |
Correct |
57 ms |
1088 KB |
Output is correct |
28 |
Correct |
52 ms |
1016 KB |
Output is correct |
29 |
Correct |
53 ms |
1084 KB |
Output is correct |
30 |
Correct |
26 ms |
1096 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |