結果

問題 No.2157 崖
ユーザー iseeisee
提出日時 2022-12-10 01:19:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 962 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 148,608 KB
最終ジャッジ日時 2024-04-22 23:35:02
合計ジャッジ時間 42,357 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
148,608 KB
testcase_01 AC 38 ms
52,480 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 44 ms
59,264 KB
testcase_04 AC 38 ms
51,968 KB
testcase_05 AC 45 ms
60,544 KB
testcase_06 AC 39 ms
52,096 KB
testcase_07 AC 50 ms
60,672 KB
testcase_08 AC 38 ms
52,224 KB
testcase_09 AC 43 ms
52,608 KB
testcase_10 AC 38 ms
52,608 KB
testcase_11 AC 51 ms
62,592 KB
testcase_12 AC 39 ms
52,352 KB
testcase_13 AC 5,735 ms
91,904 KB
testcase_14 AC 5,881 ms
96,384 KB
testcase_15 AC 5,188 ms
92,160 KB
testcase_16 AC 5,608 ms
93,344 KB
testcase_17 AC 5,311 ms
93,312 KB
testcase_18 AC 4,701 ms
93,184 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    # 入力
    N, M = map(int, input().split())
    D = [sorted(list(map(int, input().split()))) for _ in range(N)]
    # 計算・出力        
    ng = -1
    ok = 10**9
    while abs(ng-ok) > 1:
        mid = (ok+ng)//2

        dp = [True]*M
        for i in range(1, N):
            dp0 = [False]*M
            l = 0
            r = 0
            bool = 0
            for j in range(M):
                while r < M and D[i-1][r] <= D[i][j]:
                    bool += 1 if dp[r] else 0
                    r += 1
                while l < M and D[i-1][l] < D[i][j] - mid:
                    bool -= 1 if dp[l] else 0
                    l += 1
                dp0[j] = (bool > 0)
            dp = dp0
        
        if any(dp) : # ここ頑張る
            ok = mid
        else:
            ng = mid
    print(ok if ok != 10**9 else -1)

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