Submission #997432

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

using namespace std;
constexpr int inf = 1e9;
constexpr int epsilon = 1;
int d;

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

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

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

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

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

    d*=2;

    for (int i = 0; i < m; ++i) {
        int x; cin >> x;
        x *= 2;
        p.push_back(x);
        int ans = solve(p);
        cout << ans / 2 << (ans % 2 ? ".5" : "")  << " ";
    }

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