結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 40 ms
59,840 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 49 ms
64,336 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 74 ms
73,072 KB
testcase_08 AC 40 ms
58,816 KB
testcase_09 AC 43 ms
61,200 KB
testcase_10 AC 34 ms
53,460 KB
testcase_11 AC 59 ms
68,376 KB
testcase_12 AC 38 ms
53,460 KB
testcase_13 AC 4,860 ms
103,648 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
a=[]
for i in range(n):
	a+=[list(map(int,input().split()))]
	a[-1].sort()
from bisect import bisect_left,bisect_right
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)
		for j in range(m):
			if q[j]:
				l=bisect_left(a[i],a[i-1][j])
				r=bisect_right(a[i],a[i-1][j]+mid)
				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