結果

問題 No.2157 崖
ユーザー flygonflygon
提出日時 2022-12-09 23:17:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 879 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 164,536 KB
最終ジャッジ日時 2024-04-22 23:03:42
合計ジャッジ時間 10,073 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
164,536 KB
testcase_01 AC 47 ms
56,012 KB
testcase_02 AC 44 ms
55,688 KB
testcase_03 AC 60 ms
68,352 KB
testcase_04 AC 44 ms
56,744 KB
testcase_05 AC 60 ms
67,868 KB
testcase_06 AC 50 ms
56,204 KB
testcase_07 AC 68 ms
72,608 KB
testcase_08 AC 52 ms
62,224 KB
testcase_09 AC 58 ms
65,068 KB
testcase_10 AC 44 ms
55,472 KB
testcase_11 AC 68 ms
71,996 KB
testcase_12 AC 46 ms
55,820 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):
      new[j] = new[j-1]
      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] += (tmp > 0)
    dp = new
  if dp[-1] == 0 :
    l = mid
  else:
    r = mid
ans = r
print(ans) if ans != 10**9+10 else print(-1)
0