結果

問題 No.1597 Matrix Sort
コンテスト
ユーザー H3PO4
提出日時 2023-03-25 15:29:16
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 441 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 290 ms
コンパイル使用メモリ 85,440 KB
実行使用メモリ 109,756 KB
最終ジャッジ日時 2026-04-06 23:34:20
合計ジャッジ時間 30,589 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 2 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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