#include "gap.h"
#include <iostream>
#define ll long long
const ll MN = 0, MX = 1e18;
using namespace std;
ll ret = MN;
ll ar[100001];
ll findGap(int T, int N)
{
if (T == 1)
{
ll L = MN, R = MX, k = 0;
for (int i = N; i > 0; i -= 2)
{
MinMax(L, R, &ar[k], &ar[N - 1 - k]);
L = ar[k] + 1;
R = ar[N - 1 - k] - 1;
k++;
}
for (int i = 1; i < N; i++) {ret = max(ret, ar[i] - ar[i - 1]);}
}
else
{
ll lf, rg, gp;
MinMax(MN, MX, &lf, &rg);
ret = (rg - lf + N - 2) / (N - 1), gp = ret;
ll pv = -1;
for (ll i = lf; i <= rg; i += gp + 1)
{
ll t1, t2;
MinMax(i, min(i + gp, rg), &t1, &t2);
if (t1 != -1)
{
if (pv != -1) {ret = max(ret, t1 - pv);}
pv = t2;
}
}
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
12 ms |
760 KB |
Output is correct |
17 |
Correct |
12 ms |
768 KB |
Output is correct |
18 |
Correct |
12 ms |
768 KB |
Output is correct |
19 |
Correct |
12 ms |
768 KB |
Output is correct |
20 |
Correct |
9 ms |
768 KB |
Output is correct |
21 |
Correct |
49 ms |
1912 KB |
Output is correct |
22 |
Correct |
49 ms |
1912 KB |
Output is correct |
23 |
Correct |
49 ms |
1912 KB |
Output is correct |
24 |
Correct |
50 ms |
1912 KB |
Output is correct |
25 |
Correct |
41 ms |
1912 KB |
Output is correct |
26 |
Correct |
48 ms |
1960 KB |
Output is correct |
27 |
Correct |
52 ms |
1916 KB |
Output is correct |
28 |
Correct |
51 ms |
1920 KB |
Output is correct |
29 |
Correct |
49 ms |
1912 KB |
Output is correct |
30 |
Correct |
35 ms |
1912 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
512 KB |
Output is correct |
17 |
Correct |
18 ms |
512 KB |
Output is correct |
18 |
Correct |
18 ms |
512 KB |
Output is correct |
19 |
Correct |
16 ms |
512 KB |
Output is correct |
20 |
Correct |
7 ms |
512 KB |
Output is correct |
21 |
Correct |
64 ms |
1144 KB |
Output is correct |
22 |
Correct |
67 ms |
1144 KB |
Output is correct |
23 |
Correct |
64 ms |
1144 KB |
Output is correct |
24 |
Correct |
66 ms |
1144 KB |
Output is correct |
25 |
Correct |
60 ms |
1160 KB |
Output is correct |
26 |
Correct |
65 ms |
1144 KB |
Output is correct |
27 |
Correct |
76 ms |
1160 KB |
Output is correct |
28 |
Correct |
65 ms |
1144 KB |
Output is correct |
29 |
Correct |
66 ms |
1144 KB |
Output is correct |
30 |
Correct |
36 ms |
1072 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |