結果

問題 No.2157 崖
ユーザー shobonvipshobonvip
提出日時 2022-12-09 22:16:00
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 4,137 ms / 6,000 ms
コード長 837 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 115,916 KB
最終ジャッジ日時 2023-08-05 00:02:44
合計ジャッジ時間 33,798 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,416 KB
testcase_01 AC 73 ms
71,484 KB
testcase_02 AC 70 ms
71,448 KB
testcase_03 AC 76 ms
76,400 KB
testcase_04 AC 68 ms
71,636 KB
testcase_05 AC 79 ms
76,488 KB
testcase_06 AC 70 ms
71,288 KB
testcase_07 AC 80 ms
76,084 KB
testcase_08 AC 70 ms
71,448 KB
testcase_09 AC 72 ms
71,316 KB
testcase_10 AC 69 ms
71,392 KB
testcase_11 AC 84 ms
75,960 KB
testcase_12 AC 69 ms
71,364 KB
testcase_13 AC 3,399 ms
102,936 KB
testcase_14 AC 3,304 ms
112,784 KB
testcase_15 AC 3,024 ms
102,612 KB
testcase_16 AC 3,212 ms
102,600 KB
testcase_17 AC 2,035 ms
107,756 KB
testcase_18 AC 2,779 ms
106,880 KB
testcase_19 AC 4,137 ms
108,552 KB
testcase_20 AC 2,483 ms
115,916 KB
testcase_21 AC 3,075 ms
115,848 KB
testcase_22 AC 2,293 ms
106,092 KB
testcase_23 AC 69 ms
71,532 KB
testcase_24 AC 120 ms
78,768 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 d[i][pivot] <= d[i+1][j]:
			pivot += 1
		e[i][j] = pivot

suki = 10 ** 9 + 2
kirai = -1
while suki - kirai > 1:
	targ = (suki + kirai) // 2
	dp = [1] * m
	for i in range(n-1):
		pfix = [0] * (m+1)
		for j in range(m):
			pfix[j+1] = pfix[j] + dp[j]
		ndp = [0] * m
		pivot = 0
		f = [0] * m
		for j in range(m):
			while pivot < m and d[i][pivot] < d[i+1][j] - targ:
				pivot += 1
			f[j] = pivot
		for j in range(m):
			v = pfix[e[i][j]] - pfix[f[j]]
			if v >= 1: ndp[j] = 1
		dp = ndp
		#print(*dp)
	if sum(dp) == 0:
		kirai = targ
	else:
		suki = targ

if kirai >= 10 ** 9:
	print(-1)
else:
	print(suki)
0