結果

問題 No.1597 Matrix Sort
ユーザー brthyyjp
提出日時 2021-10-20 11:11:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 808 ms / 1,500 ms
コード長 498 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 75,256 KB
最終ジャッジ日時 2024-09-20 06:32:21
合計ジャッジ時間 24,887 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 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