結果

問題 No.1597 Matrix Sort
ユーザー toyuzukotoyuzuko
提出日時 2021-07-09 22:13:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 1,213 ms / 1,500 ms
コード長 532 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 102,112 KB
最終ジャッジ日時 2023-09-14 09:26:54
合計ジャッジ時間 23,205 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,176 KB
testcase_01 AC 72 ms
75,476 KB
testcase_02 AC 73 ms
75,404 KB
testcase_03 AC 1,075 ms
99,116 KB
testcase_04 AC 1,112 ms
98,852 KB
testcase_05 AC 1,140 ms
98,796 KB
testcase_06 AC 1,081 ms
98,964 KB
testcase_07 AC 1,170 ms
99,008 KB
testcase_08 AC 894 ms
98,632 KB
testcase_09 AC 1,213 ms
98,556 KB
testcase_10 AC 635 ms
100,860 KB
testcase_11 AC 546 ms
98,708 KB
testcase_12 AC 707 ms
100,100 KB
testcase_13 AC 984 ms
100,172 KB
testcase_14 AC 1,012 ms
98,784 KB
testcase_15 AC 678 ms
100,312 KB
testcase_16 AC 948 ms
100,256 KB
testcase_17 AC 1,051 ms
98,680 KB
testcase_18 AC 1,073 ms
98,796 KB
testcase_19 AC 1,000 ms
98,800 KB
testcase_20 AC 990 ms
98,628 KB
testcase_21 AC 981 ms
98,896 KB
testcase_22 AC 1,098 ms
99,244 KB
testcase_23 AC 1,102 ms
100,864 KB
testcase_24 AC 147 ms
102,112 KB
testcase_25 AC 146 ms
101,860 KB
testcase_26 AC 69 ms
71,444 KB
testcase_27 AC 66 ms
71,612 KB
testcase_28 AC 67 ms
71,460 KB
testcase_29 AC 70 ms
75,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right

N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort()
B.sort()

hi = P
lo = 0

while hi - lo > 1:
    md = (hi + lo) >> 1
    tmp = 0
    for i, a in enumerate(A):
        if a < md:
            tmp += bisect_left(B, md - a)
            tmp += N - bisect_left(B, P - a)
        else:
            tmp += bisect_left(B, P + md - a) - bisect_left(B, P - a)
    if tmp < K:
        lo = md
    else:
        hi = md

print(lo)
0