結果

問題 No.2157 崖
ユーザー 👑 timitimi
提出日時 2023-01-01 11:50:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,990 ms / 6,000 ms
コード長 507 bytes
コンパイル時間 864 ms
コンパイル使用メモリ 87,040 KB
実行使用メモリ 108,092 KB
最終ジャッジ日時 2023-08-17 23:01:56
合計ジャッジ時間 34,458 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
71,304 KB
testcase_01 AC 83 ms
71,152 KB
testcase_02 AC 118 ms
69,456 KB
testcase_03 AC 84 ms
71,040 KB
testcase_04 AC 85 ms
71,040 KB
testcase_05 AC 79 ms
71,308 KB
testcase_06 AC 85 ms
71,480 KB
testcase_07 AC 97 ms
75,908 KB
testcase_08 AC 82 ms
71,228 KB
testcase_09 AC 78 ms
71,260 KB
testcase_10 AC 77 ms
71,312 KB
testcase_11 AC 87 ms
76,280 KB
testcase_12 AC 77 ms
71,436 KB
testcase_13 AC 1,636 ms
93,296 KB
testcase_14 AC 2,777 ms
102,092 KB
testcase_15 AC 2,396 ms
94,976 KB
testcase_16 AC 2,456 ms
94,440 KB
testcase_17 AC 2,472 ms
98,124 KB
testcase_18 AC 2,447 ms
97,856 KB
testcase_19 AC 2,188 ms
97,284 KB
testcase_20 AC 3,490 ms
108,092 KB
testcase_21 AC 3,990 ms
107,704 KB
testcase_22 AC 2,829 ms
97,496 KB
testcase_23 AC 78 ms
71,220 KB
testcase_24 AC 137 ms
78,376 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