#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 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;
}
long long mi, ma;
MinMax (0, xmax, &mi, &ma);
long long L = (ma - mi) / (N - 1) + (ma - mi) % (N - 1) != 0;
int nr = 0;
long long st = mi + 1;
x[1] = mi, nr = 1;
while (st < ma)
{
long long dr = st + L - 1, y, z;
if (dr >= ma) dr = ma - 1;
MinMax (st, dr, &y, &z);
if (y != -1) x[++nr] = y;
if (y != z) x[++nr] = z;
st = dr + 1;
}
x[++nr] = ma;
long long ans = x[2] - x[1];
for (int i=2; i<nr; i++)
ans = max (ans, x[i + 1] - x[i]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
5928 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
5928 KB |
Output is correct |
16 |
Correct |
15 ms |
5928 KB |
Output is correct |
17 |
Correct |
15 ms |
5928 KB |
Output is correct |
18 |
Correct |
11 ms |
5928 KB |
Output is correct |
19 |
Correct |
18 ms |
5928 KB |
Output is correct |
20 |
Correct |
13 ms |
5928 KB |
Output is correct |
21 |
Correct |
52 ms |
5928 KB |
Output is correct |
22 |
Correct |
55 ms |
5928 KB |
Output is correct |
23 |
Correct |
60 ms |
5928 KB |
Output is correct |
24 |
Correct |
58 ms |
5928 KB |
Output is correct |
25 |
Correct |
41 ms |
5928 KB |
Output is correct |
26 |
Correct |
55 ms |
5928 KB |
Output is correct |
27 |
Correct |
56 ms |
5928 KB |
Output is correct |
28 |
Correct |
56 ms |
5928 KB |
Output is correct |
29 |
Correct |
49 ms |
5928 KB |
Output is correct |
30 |
Correct |
41 ms |
5928 KB |
Output is correct |
31 |
Correct |
0 ms |
5928 KB |
Output is correct |
32 |
Correct |
0 ms |
5928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
2 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
3 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
4 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
5 |
Partially correct |
1482 ms |
5928 KB |
Partially correct |
6 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
7 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
8 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
9 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
10 |
Partially correct |
80 ms |
5928 KB |
Partially correct |
11 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
12 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
13 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
14 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
15 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
16 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
17 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
18 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
19 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
20 |
Partially correct |
195 ms |
5928 KB |
Partially correct |
21 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
22 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
23 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
24 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
25 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
26 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
27 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
28 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
29 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
30 |
Partially correct |
296 ms |
5928 KB |
Partially correct |
31 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |
32 |
Execution timed out |
2000 ms |
5928 KB |
Execution timed out |