#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
long long x[100009];
const long long xmax = 1e18;
long long rand15 () {return rand () & 32767;}
long long rand30 () {return (rand15 () << 15LL) | rand15 ();}
long long rand60 () {return (rand30 () << 30LL) | rand30 ();}
long long overallAns = 0;
void U (long long val)
{
if (val > overallAns)
overallAns = val;
}
void divide (long long bf, long long a, long long b, long long af)
{
if (a > b) return ;
if (a == b)
{
long long x, y;
MinMax (a, b, &x, &y);
if (x == -1)
{
if (af != -1) U (af - bf);
}
else
if (af != -1)
U (af - x), U (x - bf);
return ;
}
long long mid = a + rand60 () % (b - a);
long long x, y, z, t;
MinMax (a, mid, &x, &y);
MinMax (mid + 1, b, &z, &t);
if (x == -1)
{
if (bf != -1)
{
if (z != -1) U (z - bf);
else U (af - bf);
}
}
else
{
if (bf != -1) U (x - bf);
if (x != y)
divide (x, x + 1, y - 1, y);
}
if (z == -1)
{
if (y != -1)
U (af - y);
}
else
{
if (x != -1)
U (z - y);
if (z != t)
divide (z, z + 1, t - 1, t);
if (af != -1)
U (af - t);
}
}
long long findGap(int T, int N)
{
srand (time (0));
if (T == 1)
{
long long a = 0, b = xmax;
for (int i = 1, j = N; i<=j; i ++, j --)
MinMax (a, b, &x[i], &x[j]), a = x[i] + 1, b = x[j] - 1;
long long ans = x[2] - x[1];
for (int i=1; i<N; i++)
if (x[i + 1] - x[i] > ans)
ans = x[i + 1] - x[i];
return ans;
}
divide (-1, 0, xmax, -1);
return overallAns;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5928 KB |
Output is correct |
2 |
Correct |
0 ms |
5928 KB |
Output is correct |
3 |
Correct |
0 ms |
5928 KB |
Output is correct |
4 |
Correct |
0 ms |
5928 KB |
Output is correct |
5 |
Correct |
0 ms |
5928 KB |
Output is correct |
6 |
Correct |
0 ms |
5928 KB |
Output is correct |
7 |
Correct |
0 ms |
5928 KB |
Output is correct |
8 |
Correct |
0 ms |
5928 KB |
Output is correct |
9 |
Correct |
0 ms |
5928 KB |
Output is correct |
10 |
Correct |
0 ms |
5928 KB |
Output is correct |
11 |
Correct |
1 ms |
5928 KB |
Output is correct |
12 |
Correct |
1 ms |
5928 KB |
Output is correct |
13 |
Correct |
1 ms |
5928 KB |
Output is correct |
14 |
Correct |
1 ms |
5928 KB |
Output is correct |
15 |
Correct |
1 ms |
5928 KB |
Output is correct |
16 |
Correct |
15 ms |
5928 KB |
Output is correct |
17 |
Correct |
21 ms |
5928 KB |
Output is correct |
18 |
Correct |
15 ms |
5928 KB |
Output is correct |
19 |
Correct |
15 ms |
5928 KB |
Output is correct |
20 |
Correct |
8 ms |
5928 KB |
Output is correct |
21 |
Correct |
53 ms |
5928 KB |
Output is correct |
22 |
Correct |
51 ms |
5928 KB |
Output is correct |
23 |
Correct |
58 ms |
5928 KB |
Output is correct |
24 |
Correct |
59 ms |
5928 KB |
Output is correct |
25 |
Correct |
44 ms |
5928 KB |
Output is correct |
26 |
Correct |
55 ms |
5928 KB |
Output is correct |
27 |
Correct |
55 ms |
5928 KB |
Output is correct |
28 |
Correct |
54 ms |
5928 KB |
Output is correct |
29 |
Correct |
51 ms |
5928 KB |
Output is correct |
30 |
Correct |
35 ms |
5928 KB |
Output is correct |
31 |
Correct |
0 ms |
5928 KB |
Output is correct |
32 |
Correct |
0 ms |
5928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
5928 KB |
Output is correct |
2 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
3 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
4 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
5 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
6 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
7 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
8 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
9 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
10 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
11 |
Partially correct |
1 ms |
5928 KB |
Partially correct |
12 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
13 |
Partially correct |
2 ms |
5928 KB |
Partially correct |
14 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
15 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
16 |
Partially correct |
21 ms |
5928 KB |
Partially correct |
17 |
Partially correct |
24 ms |
5928 KB |
Partially correct |
18 |
Partially correct |
19 ms |
5928 KB |
Partially correct |
19 |
Partially correct |
13 ms |
5928 KB |
Partially correct |
20 |
Partially correct |
12 ms |
5928 KB |
Partially correct |
21 |
Partially correct |
79 ms |
5928 KB |
Partially correct |
22 |
Partially correct |
73 ms |
5928 KB |
Partially correct |
23 |
Partially correct |
69 ms |
5928 KB |
Partially correct |
24 |
Partially correct |
92 ms |
5928 KB |
Partially correct |
25 |
Partially correct |
67 ms |
5928 KB |
Partially correct |
26 |
Partially correct |
75 ms |
5928 KB |
Partially correct |
27 |
Partially correct |
100 ms |
5928 KB |
Partially correct |
28 |
Partially correct |
71 ms |
5928 KB |
Partially correct |
29 |
Partially correct |
71 ms |
5928 KB |
Partially correct |
30 |
Partially correct |
42 ms |
5928 KB |
Partially correct |
31 |
Partially correct |
0 ms |
5928 KB |
Partially correct |
32 |
Partially correct |
0 ms |
5928 KB |
Partially correct |