답안 #1118186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1118186 2024-11-25T05:14:29 Z bruh Measures (CEOI22_measures) C++14
0 / 100
15 ms 3408 KB
#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();
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 3408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 3408 KB Output isn't correct
2 Halted 0 ms 0 KB -