#include <bits/stdc++.h>
#include "gap.h"
#define task "B"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 5;
ll ans = 0;
ll findGap(int t, int n)
{
if (t == 1)
{
ll l = 0, r = 1e18, a[n + 1];
for (int i = 1; i <= n && (n - i + 1) >= i; i++)
{
MinMax(l, r, &a[i], &a[n - i + 1]);
l = a[i] + 1;
r = a[n - i + 1] - 1;
}
ans = 0;
for (int i = 2; i <= n; i++)
{
ans = max(ans, a[i] - a[i - 1]);
}
return ans;
} else
{
ll l = 0, r = 1e18;
MinMax(l, r, &l, &r);
ll h = (r - l + n - 2) / (n - 1);
h--;
ll ans = 0;
ll prem = l;
for (ll i = l + 1; ; i += h + 1)
{
ll mn, mx;
MinMax(i, i + h, &mn, &mx);
ans = max(ans, mn - prem);
prem = max(prem, mx);
if (mx == r)
break;
}
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 |
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 |
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 |
10 ms |
704 KB |
Output is correct |
18 |
Correct |
11 ms |
704 KB |
Output is correct |
19 |
Correct |
11 ms |
604 KB |
Output is correct |
20 |
Correct |
8 ms |
704 KB |
Output is correct |
21 |
Correct |
38 ms |
1812 KB |
Output is correct |
22 |
Correct |
38 ms |
1736 KB |
Output is correct |
23 |
Correct |
42 ms |
1800 KB |
Output is correct |
24 |
Correct |
39 ms |
1828 KB |
Output is correct |
25 |
Correct |
34 ms |
1872 KB |
Output is correct |
26 |
Correct |
38 ms |
1852 KB |
Output is correct |
27 |
Correct |
37 ms |
1828 KB |
Output is correct |
28 |
Correct |
39 ms |
1872 KB |
Output is correct |
29 |
Correct |
44 ms |
1800 KB |
Output is correct |
30 |
Correct |
33 ms |
1832 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 |
1 ms |
324 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 |
1 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 |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
208 KB |
Output is correct |
16 |
Correct |
17 ms |
516 KB |
Output is correct |
17 |
Correct |
18 ms |
512 KB |
Output is correct |
18 |
Correct |
18 ms |
428 KB |
Output is correct |
19 |
Correct |
13 ms |
428 KB |
Output is correct |
20 |
Correct |
8 ms |
516 KB |
Output is correct |
21 |
Correct |
57 ms |
1080 KB |
Output is correct |
22 |
Correct |
55 ms |
1076 KB |
Output is correct |
23 |
Correct |
65 ms |
972 KB |
Output is correct |
24 |
Correct |
84 ms |
1080 KB |
Output is correct |
25 |
Correct |
64 ms |
1084 KB |
Output is correct |
26 |
Correct |
58 ms |
1132 KB |
Output is correct |
27 |
Correct |
55 ms |
1084 KB |
Output is correct |
28 |
Correct |
60 ms |
1084 KB |
Output is correct |
29 |
Correct |
70 ms |
972 KB |
Output is correct |
30 |
Correct |
32 ms |
1088 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |