from bisect import bisect_left,bisect_right from itertools import accumulate def is_ok(v): S = D[0] for ND in D[1:]: IMOS = [0]*(len(ND)+1) for s in S: l = bisect_left(ND,s) r = bisect_right(ND,s+v) IMOS[l]+=1 IMOS[r]-=1 NS = [] L = list(accumulate(IMOS)) for j,l in enumerate(L): if l>0 and j 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid if ok == 10**9+100: print(-1) else: print(ok)