結果

問題 No.2157 崖
ユーザー sasa8uyauyasasa8uyauya
提出日時 2024-03-19 15:56:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 516 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 94,452 KB
最終ジャッジ日時 2024-03-19 15:56:27
合計ジャッジ時間 9,117 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=[]
for i in range(n):
	a+=[list(map(int,input().split()))]
	a[-1].sort()
X=10**9+1
ok=X
ng=-1
while ok-ng>1:
	mid=(ok+ng)//2
	q=[1]*(m+1)
	q[m]=0
	for i in range(1,n):
		nq=[0]*(m+1)
		l=-1
		r=-1
		for j in range(m):
			if q[j]:
				while l<n and a[i][l]<a[i-1][j]:
					l+=1
				while r<n and a[i][r]<=a[i-1][j]+mid:
					r+=1
				nq[l]+=1
				nq[r]-=1
		for j in range(m):
			nq[j+1]+=nq[j]
			nq[j]=int(nq[j]>0)
		q=nq
	if any(q):
		ok=mid
	else:
		ng=mid
print(ok if ok<X else -1)
0