結果
問題 |
No.2157 崖
|
ユーザー |
![]() |
提出日時 | 2024-03-19 15:56:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 516 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,260 KB |
実行使用メモリ | 95,072 KB |
最終ジャッジ日時 | 2024-09-30 05:33:48 |
合計ジャッジ時間 | 8,672 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 1 |
other | WA * 8 RE * 14 |
ソースコード
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)