結果

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

ソースコード

diff #

import numpy as np

n, k, p = map(int, input().split())
A = np.array(input().split(), np.int64)
B = np.array(input().split(), np.int64)
A = np.sort(A)
B = np.sort(B)

def is_ok(x):
    cnt = 0
    cnt += np.searchsorted(B, x-A, side='right').sum()
    cnt += np.searchsorted(B, p+x-A, side='right').sum()
    cnt -= np.searchsorted(B, p-A, side='left').sum()
    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