#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[100100];
int n;
ll mx = 0;
void play(ll l, ll r) {
if (l >= r) return;
ll mid = (l + r) / 2;
ll ql, qr, _l, _r;
MinMax(l, mid, &_l, &ql);
MinMax(mid + 1, r, &qr, &_r);
if (ql == -1 && qr == -1) return;
if (ql == -1) return play(qr, r);
if (qr == -1) return play(l, ql);
if (ql != -1 && qr != -1) {
mx = max(mx, qr - ql);
play(_l, ql - 1), play(qr + 1, _r);
}
}
ll findGap(int T, int N) {
n = N;
if (T == 1) {
a[0] = 0, a[n + 1] = 1e18;
for (int i = 1;i <= (n + 1) / 2;i++) {
MinMax(a[i - 1] + 1, a[n - i + 2] - 1, &a[i], &a[n - i + 1]);
}
for (int i = 1;i < n;i++) {
mx = max(mx, a[i + 1] - a[i]);
}
return mx;
}
play(0, 1e18);
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
596 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
596 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
644 KB |
Output is correct |
17 |
Correct |
7 ms |
648 KB |
Output is correct |
18 |
Correct |
7 ms |
636 KB |
Output is correct |
19 |
Correct |
9 ms |
636 KB |
Output is correct |
20 |
Correct |
6 ms |
616 KB |
Output is correct |
21 |
Correct |
30 ms |
1844 KB |
Output is correct |
22 |
Correct |
30 ms |
1972 KB |
Output is correct |
23 |
Correct |
30 ms |
1984 KB |
Output is correct |
24 |
Correct |
33 ms |
2004 KB |
Output is correct |
25 |
Correct |
27 ms |
1980 KB |
Output is correct |
26 |
Correct |
34 ms |
1860 KB |
Output is correct |
27 |
Correct |
34 ms |
1836 KB |
Output is correct |
28 |
Correct |
33 ms |
1792 KB |
Output is correct |
29 |
Correct |
30 ms |
1888 KB |
Output is correct |
30 |
Correct |
26 ms |
1948 KB |
Output is correct |
31 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Partially correct |
1 ms |
344 KB |
Partially correct |
4 |
Partially correct |
0 ms |
344 KB |
Partially correct |
5 |
Partially correct |
0 ms |
344 KB |
Partially correct |
6 |
Partially correct |
0 ms |
344 KB |
Partially correct |
7 |
Partially correct |
0 ms |
344 KB |
Partially correct |
8 |
Incorrect |
0 ms |
596 KB |
Output isn't correct |
9 |
Partially correct |
1 ms |
344 KB |
Partially correct |
10 |
Partially correct |
0 ms |
344 KB |
Partially correct |
11 |
Partially correct |
1 ms |
344 KB |
Partially correct |
12 |
Partially correct |
1 ms |
596 KB |
Partially correct |
13 |
Partially correct |
1 ms |
344 KB |
Partially correct |
14 |
Partially correct |
1 ms |
344 KB |
Partially correct |
15 |
Partially correct |
1 ms |
596 KB |
Partially correct |
16 |
Partially correct |
14 ms |
624 KB |
Partially correct |
17 |
Partially correct |
14 ms |
644 KB |
Partially correct |
18 |
Partially correct |
14 ms |
644 KB |
Partially correct |
19 |
Partially correct |
14 ms |
640 KB |
Partially correct |
20 |
Partially correct |
10 ms |
620 KB |
Partially correct |
21 |
Partially correct |
58 ms |
1232 KB |
Partially correct |
22 |
Partially correct |
59 ms |
1232 KB |
Partially correct |
23 |
Partially correct |
55 ms |
1224 KB |
Partially correct |
24 |
Partially correct |
57 ms |
1228 KB |
Partially correct |
25 |
Partially correct |
52 ms |
1196 KB |
Partially correct |
26 |
Incorrect |
54 ms |
1220 KB |
Output isn't correct |
27 |
Partially correct |
57 ms |
1276 KB |
Partially correct |
28 |
Partially correct |
54 ms |
1220 KB |
Partially correct |
29 |
Partially correct |
55 ms |
1228 KB |
Partially correct |
30 |
Partially correct |
40 ms |
1224 KB |
Partially correct |
31 |
Partially correct |
0 ms |
344 KB |
Partially correct |
32 |
Partially correct |
0 ms |
344 KB |
Partially correct |