結果
問題 |
No.2157 崖
|
ユーザー |
![]() |
提出日時 | 2024-01-23 12:05:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,368 ms / 6,000 ms |
コード長 | 829 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 94,720 KB |
最終ジャッジ日時 | 2024-09-28 06:41:59 |
合計ジャッジ時間 | 14,541 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import sys input = sys.stdin.readline N, M = map(int, input().split()) D = [] for i in range(N): D.append(list(map(int, input().split()))) D[i].sort() def check(m): pre = [1] * M Dpre = D[0] for i in range(1, N): dp = [0] * M Di = D[i] now = 0 for j in range(M): while now < M: if Di[j] < Dpre[now]: break if pre[now] and Dpre[now] <= Di[j] <= Dpre[now] + m: dp[j] = 1 break now += 1 dp, pre = pre, dp Dpre, Di = Di, Dpre return sum(pre) yes = 10 ** 9 + 5 no = -1 if not check(yes): print(-1) exit() while yes - no != 1: mid = (yes + no)//2 if check(mid): yes = mid else: no = mid print(yes)