結果

問題 No.2157 崖
ユーザー sepa38sepa38
提出日時 2022-12-13 14:44:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-04-25 00:37:05
合計ジャッジ時間 12,332 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,864 KB
testcase_01 AC 43 ms
52,736 KB
testcase_02 AC 43 ms
52,608 KB
testcase_03 AC 58 ms
61,824 KB
testcase_04 AC 42 ms
52,352 KB
testcase_05 AC 61 ms
62,592 KB
testcase_06 AC 44 ms
52,864 KB
testcase_07 AC 68 ms
66,304 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 44 ms
52,352 KB
testcase_11 WA -
testcase_12 AC 44 ms
52,480 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
n, m = map(int, input().split())
d = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
  d[i].sort()
lim = 1 << 30
l, r = -1, lim
while r - l > 1:
  piv = (l + r) // 2
  dp = [[0] * m for i in range(n)]
  dp[0] = [1] * m
  for i in range(n-1):
    for j in range(m):
      idx = bisect.bisect(d[i], d[i+1][j])
      if 0 < idx and d[i+1][j] - d[i][idx-1] <= piv:
        dp[i+1][j] |= dp[i][idx-1]
  if sum(dp[-1]):
    r = piv
  else:
    l = piv
print(r if r < lim else -1)
0