Submission #1118168

# Submission time Handle Problem Language Result Execution time Memory
1118168 2024-11-25T04:48:18 Z bruh Measures (CEOI22_measures) C++14
0 / 100
14 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] = 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)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("APPLICATION.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
1 Incorrect 4 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3408 KB Output isn't correct
2 Halted 0 ms 0 KB -