結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 38 ms
59,832 KB
testcase_04 WA -
testcase_05 AC 38 ms
59,832 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 42 ms
59,704 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 908 ms
92,788 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 751 ms
91,124 KB
testcase_18 AC 731 ms
90,868 KB
testcase_19 WA -
testcase_20 AC 959 ms
94,964 KB
testcase_21 AC 934 ms
95,092 KB
testcase_22 AC 708 ms
90,740 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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<m and a[i][l]<a[i-1][j]:
					l+=1
				while r<m 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