結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,480 KB
testcase_01 AC 47 ms
58,880 KB
testcase_02 AC 42 ms
52,352 KB
testcase_03 AC 44 ms
53,120 KB
testcase_04 AC 42 ms
52,480 KB
testcase_05 AC 46 ms
57,600 KB
testcase_06 AC 43 ms
52,480 KB
testcase_07 AC 49 ms
59,008 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 42 ms
52,480 KB
testcase_11 WA -
testcase_12 AC 45 ms
58,240 KB
testcase_13 WA -
testcase_14 AC 496 ms
93,440 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 448 ms
91,352 KB
testcase_18 AC 431 ms
90,624 KB
testcase_19 WA -
testcase_20 AC 545 ms
94,848 KB
testcase_21 AC 530 ms
94,848 KB
testcase_22 AC 428 ms
90,240 KB
testcase_23 AC 41 ms
52,352 KB
testcase_24 AC 97 ms
76,496 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=0,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:
    if not validate(c):print(c)
    else:print(c+1)
0