Submission #398125

# Submission time Handle Problem Language Result Execution time Memory
398125 2021-05-03T18:08:56 Z palilo Cipele (COCI18_cipele) C++17
90 / 90
49 ms 2884 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
#ifdef home
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;

    vector<int> l(n), r(m);
    for (auto& x : l) cin >> x;
    for (auto& x : r) cin >> x;

    sort(l.begin(), l.end());
    sort(r.begin(), r.end());

    if (n > m) swap(n, m), swap(l, r);

    constexpr int mn = 0, mx = int(1e9) - 1;
    auto ok = [&](int lim) {
        int ptr = 0;
        for (const auto& x : l) {
            while (ptr < m && r[ptr] + lim < x) ++ptr;
            if (ptr == m || x + lim < r[ptr]) return false;
            ++ptr;
        }
        return true;
    };

    int lo = mn, hi = mx;
    while (lo != hi) {
        int mid = (lo + hi) >> 1;
        ok(mid) ? hi = mid : lo = mid + 1;
    }
    cout << lo;
}
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1100 KB Output is correct
2 Correct 45 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1100 KB Output is correct
2 Correct 45 ms 2884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 844 KB Output is correct
2 Correct 27 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 972 KB Output is correct
2 Correct 22 ms 1996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 844 KB Output is correct
2 Correct 49 ms 980 KB Output is correct