Submission #997435

# Submission time Handle Problem Language Result Execution time Memory
997435 2024-06-12T10:21:37 Z crafticat Measures (CEOI22_measures) C++17
0 / 100
1500 ms 596 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll inf = 1e9;
constexpr ll epsilon = 1;
ll d;

bool ok(vector<ll> &arr, ll move) {
    ll lastPos = -inf;
    for (auto x : arr) {
        ll req = (lastPos + d) - x;
        req = max(req, -move);
        if (req > move) return false;
        lastPos = x + req;
    }
    return true;
}

double solve(vector<ll> arr) {
    std::sort(arr.begin(), arr.end());

    ll l = 0, r = inf;
    while (r - l > 0) {
        ll mid = l + (r - l) / 2;
        if (ok(arr,mid)) {
            r = mid;
        } else {
            l = mid + epsilon;
        }
    }
    return l;
}

constexpr ll pres = 100000;

int main() {
    ll n, m; cin >> n >> m >> d;

    vector<ll> p;
    for (ll i = 0; i < n; ++i) {
        ll x; cin >> x;
        x *= pres;
        p.push_back(x);
    }

    d*=pres;

    for (ll i = 0; i < m; ++i) {
        ll x; cin >> x;
        x *= pres;
        p.push_back(x);
        ll ans = solve(p);
        cout << ans / pres;
        ans %= pres;
        if (ans != 0) cout << ".";
        ll mul = pres;
        while (ans != 0) {
            mul /= 10;
            cout << (ans / mul) % 10;
            ans %= mul;
        }
        cout << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1537 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1537 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -