#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << ": " << x << endl;
#define sep ' '
#define all(x) (x).begin(),(x).end()
const ll INF = 2e18;
ll findGap(int t, int n) {
if (t == 1) {
ll l = -1, r = INF;
vector<ll> vec;
int t = (n + 1) >> 1;
while (t-- && l < r) {
MinMax(l, r, &l, &r);
if (l != -1) {
vec.push_back(l);
vec.push_back(r);
}
l++;
r--;
}
sort(all(vec));
ll ans = 0;
for (int i = 1; i < int(vec.size()); i++)
ans = max(ans, vec[i] - vec[i - 1]);
return ans;
}
ll mn = 0, mx = INF;
MinMax(0, INF, &mn, &mx);
if (n == 1) return 0;
ll len = mx - mn;
ll sq = (len + n - 2) / (n - 1), ans = sq;
vector<ll> vec;
for (ll l = mn; l <= mx; l += sq + 1) { // sq + 1
ll a = 0, b = 0;
MinMax(l, l + sq, &a, &b); //
if (a >= 0) {
if (!vec.empty()) ans = max(ans, a - vec.back());
vec.push_back(b);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
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 |
12 ms |
848 KB |
Output is correct |
17 |
Correct |
10 ms |
876 KB |
Output is correct |
18 |
Correct |
13 ms |
880 KB |
Output is correct |
19 |
Correct |
10 ms |
872 KB |
Output is correct |
20 |
Correct |
10 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2156 KB |
Output is correct |
22 |
Correct |
39 ms |
2232 KB |
Output is correct |
23 |
Correct |
38 ms |
2140 KB |
Output is correct |
24 |
Correct |
40 ms |
2196 KB |
Output is correct |
25 |
Correct |
40 ms |
2196 KB |
Output is correct |
26 |
Correct |
42 ms |
2240 KB |
Output is correct |
27 |
Correct |
41 ms |
2204 KB |
Output is correct |
28 |
Correct |
40 ms |
2240 KB |
Output is correct |
29 |
Correct |
42 ms |
2244 KB |
Output is correct |
30 |
Correct |
34 ms |
2208 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 |
0 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 |
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 |
1 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 |
13 ms |
720 KB |
Output is correct |
17 |
Correct |
12 ms |
740 KB |
Output is correct |
18 |
Correct |
15 ms |
720 KB |
Output is correct |
19 |
Correct |
12 ms |
688 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
50 ms |
1696 KB |
Output is correct |
22 |
Correct |
57 ms |
1692 KB |
Output is correct |
23 |
Correct |
49 ms |
1692 KB |
Output is correct |
24 |
Correct |
49 ms |
1696 KB |
Output is correct |
25 |
Correct |
50 ms |
2240 KB |
Output is correct |
26 |
Correct |
58 ms |
1696 KB |
Output is correct |
27 |
Correct |
58 ms |
1696 KB |
Output is correct |
28 |
Correct |
50 ms |
1732 KB |
Output is correct |
29 |
Correct |
52 ms |
1720 KB |
Output is correct |
30 |
Correct |
26 ms |
1216 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |