結果

問題 No.2157 崖
ユーザー lloyzlloyz
提出日時 2024-01-04 00:39:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 110,704 KB
最終ジャッジ日時 2024-01-04 00:39:34
合計ジャッジ時間 12,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 WA -
testcase_09 AC 36 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 WA -
testcase_12 AC 36 ms
53,460 KB
testcase_13 WA -
testcase_14 AC 517 ms
107,504 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 455 ms
103,792 KB
testcase_18 AC 471 ms
103,024 KB
testcase_19 WA -
testcase_20 AC 563 ms
110,704 KB
testcase_21 AC 586 ms
110,448 KB
testcase_22 AC 432 ms
102,256 KB
testcase_23 AC 35 ms
53,460 KB
testcase_24 AC 56 ms
68,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
D = []
for _ in range(n):
    L = list(map(int, input().split()))
    L.sort()
    D.append(L)

INF = 10**18
DP = [[INF for _ in range(m)] for _ in range(n)]
for i in range(m):
    DP[0][i] = 0
for i in range(n - 1):
    for j in range(m):
        if DP[i][j] == INF:
            continue
        prev_d = D[i][j]
        idx = bisect_left(D[i + 1], prev_d)
        if idx == m:
            continue
        res = max(DP[i][j], D[i + 1][idx] - prev_d)
        DP[i + 1][idx] = min(DP[i + 1][idx], res)
ans = min(DP[n - 1])
if ans == INF:
    ans = -1
print(ans)
0