結果

問題 No.2157 崖
ユーザー sepa38sepa38
提出日時 2022-12-13 15:18:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 721 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 326,912 KB
最終ジャッジ日時 2024-04-25 01:06:12
合計ジャッジ時間 43,993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,736 KB
testcase_01 AC 42 ms
52,864 KB
testcase_02 AC 43 ms
52,224 KB
testcase_03 AC 48 ms
58,880 KB
testcase_04 AC 41 ms
52,096 KB
testcase_05 AC 52 ms
61,184 KB
testcase_06 AC 40 ms
52,480 KB
testcase_07 AC 55 ms
61,568 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
52,480 KB
testcase_11 WA -
testcase_12 AC 40 ms
52,736 KB
testcase_13 WA -
testcase_14 AC 4,310 ms
325,760 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 3,673 ms
316,288 KB
testcase_18 AC 3,781 ms
316,800 KB
testcase_19 WA -
testcase_20 AC 4,772 ms
326,912 KB
testcase_21 AC 5,069 ms
323,072 KB
testcase_22 AC 3,743 ms
326,912 KB
testcase_23 AC 43 ms
52,480 KB
testcase_24 AC 98 ms
77,312 KB
権限があれば一括ダウンロードができます

ソースコード

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()
# print(*d, sep = "\n")
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):
    idx = 0
    for j in range(m):
      while idx < m:
        if d[i][idx] > d[i+1][j]:
          idx -= 1
          break
        idx += 1
      if idx == -1:
        idx = 0
        continue
      idx = min(idx, m-1)
      if d[i+1][j] - d[i][idx] <= piv:
        dp[i+1][j] |= dp[i][idx]
  # print(l, r, piv)
  # print(*dp, sep = "\n")
  if sum(dp[-1]):
    r = piv
  else:
    l = piv
print(r if r < lim else -1)
0