STAND_TOTAL, GHOST_TOTAL = map(int, input().split()) STRENGTHS = list(map(int, input().split())) TARGETS = list(map(int, input().split())) assert(1 <= GHOST_TOTAL <= STAND_TOTAL <= 2*(10**5)) assert(STAND_TOTAL == len(STRENGTHS)) assert(GHOST_TOTAL == len(TARGETS)) assert(all(1 <= STRENGTHS[i] <= 10**9 for i in range(STAND_TOTAL))) assert(all(1 <= TARGETS[i] <= 10**9 for i in range(GHOST_TOTAL))) 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()