結果
| 問題 |
No.2157 崖
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2024-01-23 08:55:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 284 ms |
| コンパイル使用メモリ | 82,336 KB |
| 実行使用メモリ | 94,792 KB |
| 最終ジャッジ日時 | 2024-09-28 06:37:34 |
| 合計ジャッジ時間 | 9,475 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 8 |
ソースコード
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 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)
rlangevin