結果

問題 No.1597 Matrix Sort
ユーザー tamatotamato
提出日時 2021-07-09 21:44:52
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 719 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 87,616 KB
実行使用メモリ 103,760 KB
最終ジャッジ日時 2023-09-14 08:22:20
合計ジャッジ時間 35,972 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,844 KB
testcase_01 AC 76 ms
75,680 KB
testcase_02 AC 76 ms
75,984 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 1,133 ms
99,856 KB
testcase_11 AC 1,103 ms
97,408 KB
testcase_12 AC 1,188 ms
99,504 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 981 ms
99,584 KB
testcase_16 AC 1,462 ms
99,084 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 212 ms
103,760 KB
testcase_25 AC 190 ms
103,520 KB
testcase_26 AC 70 ms
71,828 KB
testcase_27 AC 72 ms
71,888 KB
testcase_28 AC 71 ms
71,704 KB
testcase_29 AC 77 ms
75,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    N, K, P = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    A = [a % P for a in A]
    B = [b % P for b in B]
    A.sort()
    B.sort()

    ok = P-1
    ng = -1
    mid = (ok + ng) // 2
    while ok - ng > 1:
        cnt = 0
        for a in A:
            cnt += bisect_left(B, mid - a + 1)
            cnt += bisect_left(B, P + mid - a + 1) - bisect_left(B, P - a)
        if cnt >= K:
            ok = mid
        else:
            ng = mid
        mid = (ok + ng) // 2
    print(ok)


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