#include <bits/stdc++.h>
#include "gap.h"
#define FOR(i,j,k) for(int i=j; i<=k; ++i)
#define ROF(i,j,k) for(int i=j; i>=k; --i)
#define ll long long
const ll inf = 1e18;
ll findGap (int t, int n) {
if(t == 1) {
std::vector <ll> v(n+2);
v[0] = -1, v[n+1] = inf + 1;
for(int i=1; i<=n-i+1; ++i)
MinMax (v[i-1]+1, v[n-i+2]-1, &v[i], &v[n-i+1]);
ll ans = 0;
FOR(i,2,n) ans = std::max(ans, v[i] - v[i-1]);
return ans;
} else {
ll Mn, Mx, B, ans, lst, L, R;
MinMax (0, inf, &Mn, &Mx);
ans = B = (Mx - Mn + n - 2) / (n - 1);
lst = Mn;
for(ll i=Mn+1; i<Mx; i+=B) {
MinMax (i, i+B-1, &L, &R);
if(L == -1) continue;
ans = std::max(ans, L - lst);
lst = R;
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 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 |
13 ms |
668 KB |
Output is correct |
17 |
Correct |
14 ms |
684 KB |
Output is correct |
18 |
Correct |
11 ms |
720 KB |
Output is correct |
19 |
Correct |
11 ms |
680 KB |
Output is correct |
20 |
Correct |
7 ms |
720 KB |
Output is correct |
21 |
Correct |
38 ms |
1856 KB |
Output is correct |
22 |
Correct |
44 ms |
1824 KB |
Output is correct |
23 |
Correct |
43 ms |
1864 KB |
Output is correct |
24 |
Correct |
36 ms |
1824 KB |
Output is correct |
25 |
Correct |
36 ms |
1828 KB |
Output is correct |
26 |
Correct |
40 ms |
1864 KB |
Output is correct |
27 |
Correct |
39 ms |
1752 KB |
Output is correct |
28 |
Correct |
40 ms |
1824 KB |
Output is correct |
29 |
Correct |
36 ms |
1848 KB |
Output is correct |
30 |
Correct |
28 ms |
1860 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 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 |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
15 ms |
496 KB |
Output is correct |
17 |
Correct |
12 ms |
464 KB |
Output is correct |
18 |
Correct |
13 ms |
416 KB |
Output is correct |
19 |
Correct |
17 ms |
512 KB |
Output is correct |
20 |
Correct |
7 ms |
464 KB |
Output is correct |
21 |
Correct |
57 ms |
968 KB |
Output is correct |
22 |
Correct |
57 ms |
1032 KB |
Output is correct |
23 |
Correct |
51 ms |
1068 KB |
Output is correct |
24 |
Correct |
56 ms |
1060 KB |
Output is correct |
25 |
Correct |
51 ms |
1060 KB |
Output is correct |
26 |
Correct |
52 ms |
1088 KB |
Output is correct |
27 |
Correct |
51 ms |
1088 KB |
Output is correct |
28 |
Correct |
58 ms |
1080 KB |
Output is correct |
29 |
Correct |
54 ms |
1060 KB |
Output is correct |
30 |
Correct |
28 ms |
968 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |