#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N) {
if (T == 1) {
long long mi = 0;
long long mx = 1e18L;
int lt = 0;
int rt = N - 1;
vector<long long> a(N);
while (lt <= rt) {
MinMax(mi, mx, &mi, &mx);
a[lt] = mi;
a[rt] = mx;
mi++;
mx--;
lt++;
rt--;
}
long long res = 0;
for (int i = 1; i < N; i++) {
res = max(res, a[i] - a[i - 1]);
}
return res;
}
else {
long long mi = 0;
long long mx = 1e18L;
MinMax(mi, mx, &mi, &mx);
long long len = (mx - mi - 1) / (N - 1) + 1;
vector<long long> a;
a.push_back(mi);
for (int i = 1; i <= N - 1; i++) {
long long lt = mi + 1 + len * (i - 1);
long long rt = mi + len * i;
MinMax(lt, rt, <, &rt);
if (lt != -1) {
a.push_back(lt);
a.push_back(rt);
}
}
long long res = 0;
for (int i = 1; i < (int)a.size(); i++) {
res = max(res, a[i] - a[i - 1]);
}
return res;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
720 KB |
Output is correct |
17 |
Correct |
10 ms |
720 KB |
Output is correct |
18 |
Correct |
10 ms |
720 KB |
Output is correct |
19 |
Correct |
10 ms |
720 KB |
Output is correct |
20 |
Correct |
8 ms |
592 KB |
Output is correct |
21 |
Correct |
48 ms |
1772 KB |
Output is correct |
22 |
Correct |
44 ms |
1824 KB |
Output is correct |
23 |
Correct |
41 ms |
1804 KB |
Output is correct |
24 |
Correct |
36 ms |
1828 KB |
Output is correct |
25 |
Correct |
40 ms |
1828 KB |
Output is correct |
26 |
Correct |
34 ms |
1876 KB |
Output is correct |
27 |
Correct |
41 ms |
1868 KB |
Output is correct |
28 |
Correct |
46 ms |
1768 KB |
Output is correct |
29 |
Correct |
37 ms |
1840 KB |
Output is correct |
30 |
Correct |
28 ms |
1872 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
14 ms |
848 KB |
Output is correct |
17 |
Correct |
12 ms |
884 KB |
Output is correct |
18 |
Correct |
12 ms |
848 KB |
Output is correct |
19 |
Correct |
12 ms |
860 KB |
Output is correct |
20 |
Correct |
5 ms |
464 KB |
Output is correct |
21 |
Correct |
66 ms |
2180 KB |
Output is correct |
22 |
Correct |
48 ms |
2204 KB |
Output is correct |
23 |
Correct |
50 ms |
2328 KB |
Output is correct |
24 |
Correct |
51 ms |
2296 KB |
Output is correct |
25 |
Correct |
50 ms |
3188 KB |
Output is correct |
26 |
Correct |
50 ms |
2204 KB |
Output is correct |
27 |
Correct |
49 ms |
2176 KB |
Output is correct |
28 |
Correct |
52 ms |
2204 KB |
Output is correct |
29 |
Correct |
54 ms |
2224 KB |
Output is correct |
30 |
Correct |
27 ms |
1444 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |