結果

問題 No.2157 崖
ユーザー shobonvipshobonvip
提出日時 2022-12-09 21:51:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 111,648 KB
最終ジャッジ日時 2024-04-22 21:46:16
合計ジャッジ時間 8,356 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,948 KB
testcase_01 AC 36 ms
52,868 KB
testcase_02 AC 37 ms
53,284 KB
testcase_03 AC 37 ms
52,464 KB
testcase_04 AC 37 ms
54,104 KB
testcase_05 AC 35 ms
53,092 KB
testcase_06 AC 37 ms
52,320 KB
testcase_07 AC 37 ms
53,088 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 36 ms
52,460 KB
testcase_11 WA -
testcase_12 AC 36 ms
52,476 KB
testcase_13 WA -
testcase_14 AC 628 ms
108,764 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 519 ms
104,360 KB
testcase_18 AC 537 ms
103,836 KB
testcase_19 WA -
testcase_20 AC 682 ms
111,648 KB
testcase_21 AC 674 ms
111,456 KB
testcase_22 AC 518 ms
102,804 KB
testcase_23 AC 36 ms
53,804 KB
testcase_24 AC 71 ms
73,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
d = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
	d[i].sort()
e = [[0] * m for i in range(n-1)]

for i in range(n-1):
	pivot = 0
	for j in range(m):
		while pivot < m and (pivot < 0 or d[i][pivot] <= d[i+1][j]):
			pivot += 1
		pivot -= 1
		e[i][j] = pivot

dp = [0] * m
for i in range(n-1):
	ndp = [10**18] * (m)
	for j in range(m):
		if e[i][j] >= 0:
			ndp[j] = max(dp[e[i][j]], d[i+1][j] - d[i][e[i][j]])
	dp = ndp

#print(dp)

if min(dp) >= 10**14:
	print(-1)
else:
	print(min(dp))
0