#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
ll a[100000];
ll findGap(int T, int N)
{
if (T == 1)
{
ll lo = 0, hi = 1000000000000000000;
int l = 0, r = N - 1;
while (l <= r)
{
MinMax(lo, hi, &a[l], &a[r]);
lo = a[l++] + 1;
hi = a[r--] - 1;
}
ll mx = 0;
for (int i = 0; i < N; i++)
mx = max(mx, a[i+1] - a[i]);
return mx;
}
else
{
ll lo, hi;
MinMax(0, 1e18, &lo, &hi);
ll ans = (hi - lo) / (N - 1), last = lo;
for (ll i = lo; i <= hi; )
{
ll x, y;
MinMax(i + 1, i + ans, &x, &y);
i += ans;
if (x != -1)
{
ans = max(ans, x - last);
last = y;
}
}
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 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 |
592 KB |
Output is correct |
17 |
Correct |
9 ms |
692 KB |
Output is correct |
18 |
Correct |
9 ms |
688 KB |
Output is correct |
19 |
Correct |
9 ms |
592 KB |
Output is correct |
20 |
Correct |
8 ms |
592 KB |
Output is correct |
21 |
Correct |
36 ms |
1816 KB |
Output is correct |
22 |
Correct |
36 ms |
1864 KB |
Output is correct |
23 |
Correct |
37 ms |
1832 KB |
Output is correct |
24 |
Correct |
44 ms |
1928 KB |
Output is correct |
25 |
Correct |
37 ms |
1768 KB |
Output is correct |
26 |
Correct |
41 ms |
1828 KB |
Output is correct |
27 |
Correct |
35 ms |
1856 KB |
Output is correct |
28 |
Correct |
37 ms |
1788 KB |
Output is correct |
29 |
Correct |
36 ms |
1864 KB |
Output is correct |
30 |
Correct |
34 ms |
1732 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 |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 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 |
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 |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
7 ms |
464 KB |
Output is correct |
17 |
Correct |
8 ms |
428 KB |
Output is correct |
18 |
Correct |
6 ms |
464 KB |
Output is correct |
19 |
Correct |
6 ms |
464 KB |
Output is correct |
20 |
Correct |
5 ms |
524 KB |
Output is correct |
21 |
Correct |
30 ms |
1060 KB |
Output is correct |
22 |
Correct |
29 ms |
968 KB |
Output is correct |
23 |
Correct |
22 ms |
968 KB |
Output is correct |
24 |
Correct |
28 ms |
1064 KB |
Output is correct |
25 |
Correct |
46 ms |
1044 KB |
Output is correct |
26 |
Correct |
22 ms |
984 KB |
Output is correct |
27 |
Correct |
30 ms |
1064 KB |
Output is correct |
28 |
Correct |
23 ms |
1068 KB |
Output is correct |
29 |
Correct |
23 ms |
1168 KB |
Output is correct |
30 |
Correct |
22 ms |
1104 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |