結果

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

ソースコード

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)
    return cnt >= k

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