#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int t, int n) {
if (t == 1) {
vector<long long> a(n + 1);
long long l = 0, r = 1e18L;
for (int i = 1; i <= (n + 1) / 2; ++i) {
MinMax(l, r, &a[i], &a[n - i + 1]);
l = a[i] + 1, r = a[n - i + 1] - 1;
}
long long ans = 0;
for (int i = 2; i <= n; ++i) {
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
}
long long first, last;
MinMax(0, 1e18L, &first, &last);
long long buck = (last - first) / (n - 1), ans = 0, prv = first;
for (long long i = first + 1; i <= last; i += buck + 1) {
long long x, y;
MinMax(i, i + buck, &x, &y);
if (x != -1) {
ans = max(ans, x - prv);
prv = y;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
248 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 |
328 KB |
Output is correct |
12 |
Correct |
2 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
9 ms |
676 KB |
Output is correct |
17 |
Correct |
11 ms |
712 KB |
Output is correct |
18 |
Correct |
9 ms |
612 KB |
Output is correct |
19 |
Correct |
9 ms |
712 KB |
Output is correct |
20 |
Correct |
7 ms |
712 KB |
Output is correct |
21 |
Correct |
36 ms |
1824 KB |
Output is correct |
22 |
Correct |
39 ms |
1752 KB |
Output is correct |
23 |
Correct |
44 ms |
1808 KB |
Output is correct |
24 |
Correct |
41 ms |
1952 KB |
Output is correct |
25 |
Correct |
32 ms |
1864 KB |
Output is correct |
26 |
Correct |
37 ms |
1840 KB |
Output is correct |
27 |
Correct |
37 ms |
1856 KB |
Output is correct |
28 |
Correct |
39 ms |
1836 KB |
Output is correct |
29 |
Correct |
38 ms |
1856 KB |
Output is correct |
30 |
Correct |
29 ms |
1864 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
13 ms |
472 KB |
Output is correct |
17 |
Correct |
13 ms |
448 KB |
Output is correct |
18 |
Correct |
16 ms |
456 KB |
Output is correct |
19 |
Correct |
17 ms |
504 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
51 ms |
1180 KB |
Output is correct |
22 |
Correct |
49 ms |
1052 KB |
Output is correct |
23 |
Correct |
49 ms |
1080 KB |
Output is correct |
24 |
Correct |
53 ms |
1028 KB |
Output is correct |
25 |
Correct |
46 ms |
1072 KB |
Output is correct |
26 |
Correct |
52 ms |
1052 KB |
Output is correct |
27 |
Correct |
52 ms |
1092 KB |
Output is correct |
28 |
Correct |
75 ms |
1048 KB |
Output is correct |
29 |
Correct |
54 ms |
1040 KB |
Output is correct |
30 |
Correct |
28 ms |
1000 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |