#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 100;
int n, m, d;
int a[maxn], pos[maxn];
bool check(int dist, int m)
{
int mid = m / 2 + 1;
pos[m + 1] = 1e18;
pos[0] = -1e18;
for (int i = m; i >= mid; i--)
pos[i] = max(a[i], min(a[i] + dist, pos[i + 1] - d));
for (int i = 1; i < mid; i++)
pos[i] = min(a[i], max(a[i] - dist, pos[i - 1] + d));
for (int i = 1; i < m; i++)
if (pos[i + 1] - pos[i] < d)
return 0;;
return 1;
}
void sub12()
{
for (int i = 1; i <= m; i++)
{
sort(a + 1, a + n + i + 1);
int l = 0, r = (int)4e14, ans = -1;
while (l <= r)
{
int mid = (l + r) / 2;
if (check(mid, n + i))
ans = mid, r = mid - 1;
else l = mid + 1;
}
if (ans % 2) cout << ans / 2 << ".5 ";
else cout << ans / 2 << " ";
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> m >> d;
d *= 2;
for (int i = 1; i <= n; i++)
cin >> a[i], a[i] *= 2;
for (int i = 1; i <= m; i++)
cin >> a[i + n], a[i + n] *= 2;
if (m <= 10)
sub12();
// else sub3();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
3408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
3408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |