#include [[nodiscard]] static inline constexpr bool check(const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector& S, const std::vector>& T, const uint_fast32_t x) noexcept { [[assume(std::is_sorted(S.begin(), S.end()))]]; [[assume(std::is_sorted(T.begin(), T.end()))]]; uint_fast32_t i = 0; for (const auto& [t, index] : T) if (index < x) { while (i < N && S[i] < t) ++i; if (i >= N) return false; ++i; } return true; } [[nodiscard]] static inline constexpr uint_fast64_t evaluate([[maybe_unused]] const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector& S, const std::vector>& T, const uint_fast32_t x) noexcept { [[assume(std::is_sorted(S.begin(), S.end()))]]; [[assume(std::is_sorted(T.begin(), T.end()))]]; uint_fast32_t ans = 0, i = 0; for (const auto& [t, index] : T) if (index < x) { while (S[i] < t) ++i; ans = std::max(ans, S[i++] - t); } return ans; } [[nodiscard]] static inline constexpr uint_fast64_t solve(const uint_fast32_t N, const uint_fast32_t M, const std::vector& S, const std::vector>& T) noexcept { [[assume(std::is_sorted(S.begin(), S.end()))]]; [[assume(std::is_sorted(T.begin(), T.end()))]]; uint_fast32_t l = 0, r = M + 1; while (l + 1 < r) { const uint_fast32_t x = (l + r) / 2; if (check(N, M, S, T, x)) l = x; else r = x; } return evaluate(N, M, S, T, l); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M; std::cin >> N >> M; std::vector S(N); std::vector> T(M); for (auto& s : S) std::cin >> s; for (uint_fast32_t i = 0; i < M; ++i) std::cin >> T[i].first, T[i].second = i; std::sort(S.begin(), S.end()); std::sort(T.begin(), T.end()); std::cout << solve(N, M, S, T) << '\n'; return 0; }