結果

問題 No.1597 Matrix Sort
ユーザー H3PO4H3PO4
提出日時 2023-03-25 15:29:16
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 441 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 99,376 KB
最終ジャッジ日時 2023-10-19 02:02:03
合計ジャッジ時間 15,376 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,692 KB
testcase_01 AC 44 ms
59,176 KB
testcase_02 AC 47 ms
59,172 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,253 ms
94,448 KB
testcase_11 AC 1,150 ms
94,608 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 982 ms
94,416 KB
testcase_16 AC 1,431 ms
95,140 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 147 ms
98,452 KB
testcase_25 AC 127 ms
98,452 KB
testcase_26 WA -
testcase_27 AC 38 ms
53,692 KB
testcase_28 AC 38 ms
53,692 KB
testcase_29 AC 45 ms
61,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right

N, K, P = map(int, input().split())
A = tuple(int(x) % P for x in input().split())
B = sorted(int(x) % P for x in input().split())


def lower(x):
    ct = 0
    for a in A:
        ct += bisect_right(B, x - a) + bisect_right(B, P + x - a) - bisect_right(B, P - a - 1)
    return ct


l, r = 0, P
while r - l > 1:
    m = (r + l) // 2
    if lower(m) >= K:
        r = m
    else:
        l = m
print(l + 1)
0