Submission #398124

# Submission time Handle Problem Language Result Execution time Memory
398124 2021-05-03T18:07:38 Z palilo Cipele (COCI18_cipele) C++17
54 / 90
49 ms 2892 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 (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 29 ms 2636 KB Output is correct
2 Correct 49 ms 2884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 2892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 460 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 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 3 ms 460 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 44 ms 2360 KB Output is correct
2 Correct 27 ms 1812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 2608 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2244 KB Output is correct
2 Incorrect 43 ms 2516 KB Output isn't correct