結果

問題 No.1597 Matrix Sort
ユーザー brthyyjp
提出日時 2021-10-20 11:06:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 480 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 104,276 KB
最終ジャッジ日時 2024-09-20 06:31:51
合計ジャッジ時間 30,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, p = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort()
B.sort()

import bisect
def is_ok(x):
    cnt = 0
    for a in A:
        cnt += bisect.bisect_right(B, x-a)
        cnt += bisect.bisect_right(B, p+x-a)-bisect.bisect_left(B, p-a)
        if cnt >= k:
            return True
    return False

ng = -1
ok = p
while ng+1 < ok:
    c = (ng+ok)//2
    if is_ok(c):
        ok = c
    else:
        ng = c
print(ok)
0