結果

問題 No.2157 崖
ユーザー 👑 timitimi
提出日時 2023-01-01 11:50:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,229 ms / 6,000 ms
コード長 507 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 106,496 KB
最終ジャッジ日時 2024-05-05 05:48:07
合計ジャッジ時間 26,979 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,224 KB
testcase_01 AC 38 ms
52,352 KB
testcase_02 AC 38 ms
52,224 KB
testcase_03 AC 38 ms
52,480 KB
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 44 ms
52,736 KB
testcase_06 AC 41 ms
51,968 KB
testcase_07 AC 48 ms
61,312 KB
testcase_08 AC 42 ms
52,352 KB
testcase_09 AC 39 ms
52,608 KB
testcase_10 AC 36 ms
51,840 KB
testcase_11 AC 47 ms
61,056 KB
testcase_12 AC 38 ms
51,840 KB
testcase_13 AC 1,340 ms
91,264 KB
testcase_14 AC 2,178 ms
100,992 KB
testcase_15 AC 1,919 ms
93,184 KB
testcase_16 AC 2,008 ms
93,056 KB
testcase_17 AC 1,935 ms
96,896 KB
testcase_18 AC 1,934 ms
97,024 KB
testcase_19 AC 1,814 ms
95,744 KB
testcase_20 AC 2,763 ms
106,496 KB
testcase_21 AC 3,229 ms
105,728 KB
testcase_22 AC 2,313 ms
96,256 KB
testcase_23 AC 36 ms
52,096 KB
testcase_24 AC 96 ms
77,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
D=[]
for i in range(N):
  A=list(map(int, input().split()))
  A=sorted(A)
  D.append(A)

ok,ng=-1,10**9+1
while abs(ok-ng)>1:
#for _ in range(10):
  mid=(ok+ng)//2
  A=D[0]
  for i in range(1,N):
    B=D[i]
    b=-1
    AA=[]
    for a in A:
      while b+1<M and a+mid>=B[b+1]:
        if a<=B[b+1]:
          AA.append(B[b+1])
        b+=1
    A=sorted(list(set(AA)))
  if len(A)==0:
    ok=mid
  else:
    ng=mid
  #print(ok,ng)
if ng==10**9+1:
  print(-1)
else:
  print(ng)
0