結果

問題 No.2157 崖
ユーザー achapiachapi
提出日時 2022-12-09 22:19:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 95,144 KB
最終ジャッジ日時 2024-04-22 22:27:01
合計ジャッジ時間 7,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,956 KB
testcase_01 AC 39 ms
59,948 KB
testcase_02 AC 33 ms
53,820 KB
testcase_03 AC 34 ms
53,684 KB
testcase_04 AC 35 ms
53,364 KB
testcase_05 AC 36 ms
57,860 KB
testcase_06 AC 34 ms
53,140 KB
testcase_07 AC 39 ms
59,980 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 34 ms
53,140 KB
testcase_11 WA -
testcase_12 AC 39 ms
59,336 KB
testcase_13 WA -
testcase_14 AC 423 ms
93,180 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 370 ms
91,244 KB
testcase_18 AC 369 ms
90,812 KB
testcase_19 WA -
testcase_20 AC 463 ms
94,664 KB
testcase_21 AC 451 ms
95,144 KB
testcase_22 AC 349 ms
90,796 KB
testcase_23 AC 34 ms
53,540 KB
testcase_24 AC 73 ms
76,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(n)]
for i in range(n):s[i].sort()
from bisect import*
def le(a, x):
    i = bisect_right(a, x)
    if i:return a[i-1]
    return -1
def validate(x):
    ans=10**18
    for i in range(m):
        c=s[0][i]
        k=0
        for j in range(1,n):
            r=le(s[j],c+x)
            if r==-1 or r<c:break
            k=max(k,r-c)
            c=r
        else:ans=min(ans,k)
    if ans==10**18:return True
    else:return False
def binarysearch(left=-1,right=10**18,r=0):
    while left<=right:
        mid=(left+right)//2
        if validate(mid):r=mid;left=mid+1
        else:right=mid-1
    return r
c=binarysearch()
if c==10**18:print(-1)
else:
    print(c+1)
0