結果

問題 No.1597 Matrix Sort
ユーザー NSNS
提出日時 2021-07-10 14:22:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 586 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 103,144 KB
最終ジャッジ日時 2023-09-14 19:23:56
合計ジャッジ時間 37,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,128 KB
testcase_01 AC 81 ms
75,216 KB
testcase_02 AC 78 ms
75,232 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 1,209 ms
100,468 KB
testcase_11 AC 1,204 ms
99,468 KB
testcase_12 AC 1,167 ms
102,964 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 979 ms
103,144 KB
testcase_16 AC 1,373 ms
101,280 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 1,495 ms
100,860 KB
testcase_24 AC 188 ms
102,040 KB
testcase_25 AC 173 ms
101,948 KB
testcase_26 AC 72 ms
71,296 KB
testcase_27 AC 71 ms
71,264 KB
testcase_28 AC 71 ms
71,480 KB
testcase_29 AC 81 ms
75,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,p=map(int, input().split())
al=list(map(int, input().split()))
bl=list(map(int, input().split()))
al.sort()
bl.sort()

from bisect import bisect_left, bisect_right
def check_cnt(val):
    res=0
    for a in al:
        cnt1 = bisect_right(bl, val-a)
        cnt2 = n - bisect_left(bl, p-a)
        cnt3 = n - bisect_right(bl, val+p-a)
        res+=(cnt1+cnt2-cnt3)
    return res

ok, ng = 0, p
ok, ng = p-1, -1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    res = True
    # ...
    cnt=check_cnt(mid)
    # print('---',mid,cnt)
    if cnt>=k: ok = mid
    else: ng = mid
print(ok)
0