結果

問題 No.1597 Matrix Sort
ユーザー brthyyjpbrthyyjp
提出日時 2021-10-20 11:11:22
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,118 ms / 1,500 ms
コード長 498 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 11,880 KB
実行使用メモリ 75,128 KB
最終ジャッジ日時 2023-10-20 10:58:09
合計ジャッジ時間 24,367 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,118 ms
42,240 KB
testcase_01 AC 460 ms
42,448 KB
testcase_02 AC 456 ms
42,328 KB
testcase_03 AC 731 ms
48,780 KB
testcase_04 AC 761 ms
48,780 KB
testcase_05 AC 780 ms
48,780 KB
testcase_06 AC 773 ms
48,780 KB
testcase_07 AC 795 ms
48,780 KB
testcase_08 AC 727 ms
48,780 KB
testcase_09 AC 737 ms
48,780 KB
testcase_10 AC 593 ms
48,780 KB
testcase_11 AC 649 ms
48,780 KB
testcase_12 AC 631 ms
49,204 KB
testcase_13 AC 665 ms
48,668 KB
testcase_14 AC 742 ms
48,780 KB
testcase_15 AC 584 ms
49,204 KB
testcase_16 AC 647 ms
48,672 KB
testcase_17 AC 753 ms
48,780 KB
testcase_18 AC 801 ms
48,780 KB
testcase_19 AC 735 ms
48,780 KB
testcase_20 AC 722 ms
48,772 KB
testcase_21 AC 716 ms
48,716 KB
testcase_22 AC 703 ms
48,176 KB
testcase_23 AC 623 ms
47,272 KB
testcase_24 AC 506 ms
44,444 KB
testcase_25 AC 513 ms
44,444 KB
testcase_26 AC 460 ms
42,408 KB
testcase_27 AC 462 ms
42,548 KB
testcase_28 AC 459 ms
42,324 KB
testcase_29 AC 462 ms
75,128 KB
権限があれば一括ダウンロードができます

ソースコード

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