#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cdiv(ll a, ll b){
return (a + b - 1) / b;
}
ll findGap(int T, int N){
if (T == 1){
vector<ll> vec(N);
ll lv = 0, rv = 1e18, ans = 0;
for (int l = 0, r = N - 1; l <= r; l++, r--){
MinMax(lv, rv, &vec[l], &vec[r]);
lv = vec[l] + 1; rv = vec[r] - 1;
}
for (int i = 1; i < N; i++) ans = max(ans, vec[i] - vec[i - 1]);
return ans;
}
else{
ll mn, mx; MinMax(0, 1e18, &mn, &mx);
ll gap = cdiv(mx - mn, N - 1), prv = mn, ans = 0;
for (ll x = mn + 1; x <= mx; x += gap){
ll mnh, mxh; MinMax(x, min(x + gap - 1, mx), &mnh, &mxh);
if (mnh == -1) continue;
ans = max(ans, mnh - prv);
prv = mxh;
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
8 ms |
2580 KB |
Output is correct |
17 |
Correct |
10 ms |
668 KB |
Output is correct |
18 |
Correct |
8 ms |
644 KB |
Output is correct |
19 |
Correct |
7 ms |
636 KB |
Output is correct |
20 |
Correct |
7 ms |
824 KB |
Output is correct |
21 |
Correct |
29 ms |
1980 KB |
Output is correct |
22 |
Correct |
29 ms |
1976 KB |
Output is correct |
23 |
Correct |
31 ms |
1948 KB |
Output is correct |
24 |
Correct |
29 ms |
1980 KB |
Output is correct |
25 |
Correct |
27 ms |
1996 KB |
Output is correct |
26 |
Correct |
30 ms |
1832 KB |
Output is correct |
27 |
Correct |
30 ms |
1972 KB |
Output is correct |
28 |
Correct |
29 ms |
1976 KB |
Output is correct |
29 |
Correct |
30 ms |
2200 KB |
Output is correct |
30 |
Correct |
26 ms |
1900 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
532 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
1 ms |
596 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
10 ms |
644 KB |
Output is correct |
17 |
Correct |
10 ms |
636 KB |
Output is correct |
18 |
Correct |
10 ms |
644 KB |
Output is correct |
19 |
Correct |
10 ms |
636 KB |
Output is correct |
20 |
Correct |
5 ms |
620 KB |
Output is correct |
21 |
Correct |
44 ms |
1216 KB |
Output is correct |
22 |
Correct |
40 ms |
1220 KB |
Output is correct |
23 |
Correct |
40 ms |
1208 KB |
Output is correct |
24 |
Correct |
41 ms |
1216 KB |
Output is correct |
25 |
Correct |
38 ms |
2848 KB |
Output is correct |
26 |
Correct |
47 ms |
2856 KB |
Output is correct |
27 |
Correct |
40 ms |
2860 KB |
Output is correct |
28 |
Correct |
40 ms |
2856 KB |
Output is correct |
29 |
Correct |
40 ms |
1208 KB |
Output is correct |
30 |
Correct |
23 ms |
1120 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
344 KB |
Output is correct |