結果

問題 No.2157 崖
ユーザー flygonflygon
提出日時 2022-12-09 23:14:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 859 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 82,152 KB
実行使用メモリ 270,920 KB
最終ジャッジ日時 2024-04-22 23:03:06
合計ジャッジ時間 9,688 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,892 KB
testcase_01 AC 44 ms
55,984 KB
testcase_02 AC 38 ms
55,424 KB
testcase_03 AC 50 ms
66,792 KB
testcase_04 AC 40 ms
56,432 KB
testcase_05 AC 55 ms
68,204 KB
testcase_06 AC 40 ms
55,920 KB
testcase_07 AC 57 ms
72,124 KB
testcase_08 AC 42 ms
61,936 KB
testcase_09 AC 48 ms
65,020 KB
testcase_10 AC 41 ms
55,532 KB
testcase_11 AC 58 ms
71,908 KB
testcase_12 AC 38 ms
56,156 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 sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,m = map(int,input().split())
d  = [[-1] + list(map(int,input().split())) for i in range(n)]
for i in range(n):
  d[i].sort()
  
m+= 1
_ = [i for i in range(m)]
l = -1
r = 10**9+10
while r-l > 1:
  mid = (r+l)//2
  dp = _[::1]
  for i in range(1, n):
    dd = d[i]
    new = [0]*(m)
    for j in range(1,m):
      ll = bisect_left(d[i-1], max(1,dd[j]-mid))
      rr = bisect_right(d[i-1], dd[j])
      tmp = dp[rr-1] - dp[ll-1]
      new[j] = new[j-1] + tmp
    dp = new
  if dp[-1] == 0 :
    l = mid
  else:
    r = mid
ans = r
print(ans) if ans != 10**9+10 else print(-1)
0