이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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] = min(a[i] + dist, pos[i + 1] - d);
        if (abs(pos[i] - a[i]) > dist) return 0;
    }
    for (int i = 1; i < mid; i++)
    {
        pos[i] = max(a[i] - dist, pos[i - 1] + d);
        if (abs(pos[i] - a[i]) > dist) return 0;
    }
    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 <= 1; i++)
    {
        sort(a + 1, a + n + i + 1);
        int l = 0, r = (int)1e15, 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);
//    freopen("test.inp", "r", stdin);
//    freopen("APPLICATION.out", "w", stdout);
    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();
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |