STAND_TOTAL, GHOST_TOTAL = map(int, input().split()) STRENGTHS = list(map(int, input().split())) TARGETS = list(map(int, input().split())) def main(): STRENGTHS.sort() ok, ng = 0, GHOST_TOTAL + 1 while abs(ok - ng) > 1: med = (ok + ng) // 2 if judge(med) > -1: ok = med else: ng = med print(judge(ok)) def judge(x): if x == 0: return 0 sub_targets = [TARGETS[case_i] for case_i in range(x)] sub_targets.sort() res = 0 ghost_i = 0 for strength in STRENGTHS: target = sub_targets[ghost_i] if strength >= target: ghost_i += 1 res = max(res, strength - target) if ghost_i >= x: break if ghost_i >= x: return res else: return -1 if __name__ == "__main__": main()