結果

問題 No.2157 崖
ユーザー 👑 H20H20
提出日時 2022-12-09 22:46:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,057 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 169,496 KB
最終ジャッジ日時 2024-04-22 22:48:25
合計ジャッジ時間 14,238 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,240 KB
testcase_01 AC 34 ms
53,428 KB
testcase_02 AC 35 ms
52,880 KB
testcase_03 AC 39 ms
59,448 KB
testcase_04 AC 34 ms
53,332 KB
testcase_05 AC 42 ms
62,344 KB
testcase_06 AC 34 ms
53,340 KB
testcase_07 AC 58 ms
70,532 KB
testcase_08 AC 40 ms
58,120 KB
testcase_09 AC 44 ms
60,544 KB
testcase_10 AC 34 ms
52,876 KB
testcase_11 AC 50 ms
65,116 KB
testcase_12 AC 36 ms
54,332 KB
testcase_13 AC 4,492 ms
128,408 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 #

from bisect import bisect_left,bisect_right 
from itertools import accumulate
from sys import stdin

def main():
    N,M = map(int, stdin.readline().split())
    L = [list(map(int, stdin.readline().split())) for _ in range(N)]
    D = []
    for l in L:
        D.append(sorted(list(set(l))))
    ng = -1
    ok = 10**9+100
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        S = list(range(len(D[0])))
        for i in range(N-1):
            ND = D[i+1]
            IMOS = [0]*(len(ND)+1)
            for s in S:
                d = D[i][s]
                l = bisect_left(ND,d)
                r = bisect_right(ND,d+mid)
                IMOS[l]+=1
                IMOS[r]-=1
            NS = []
            L = list(accumulate(IMOS))
            for j,l in enumerate(L):
                if l>0 and j<len(ND):
                    NS.append(j)
            S = NS
        if S:
            ok = mid
        else:
            ng = mid
    if ok == 10**9+100:
        print(-1)
    else:
        print(ok)

if __name__ == '__main__':
    main()
0