結果

問題 No.1597 Matrix Sort
ユーザー NSNS
提出日時 2021-07-10 14:24:16
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 631 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 103,048 KB
最終ジャッジ日時 2023-09-14 19:25:08
合計ジャッジ時間 36,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,468 KB
testcase_01 AC 78 ms
75,440 KB
testcase_02 AC 78 ms
75,044 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,085 ms
100,740 KB
testcase_11 AC 1,104 ms
99,844 KB
testcase_12 AC 1,215 ms
103,048 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,010 ms
103,048 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 208 ms
102,260 KB
testcase_25 AC 188 ms
102,028 KB
testcase_26 AC 72 ms
71,524 KB
testcase_27 AC 70 ms
71,228 KB
testcase_28 AC 72 ms
71,004 KB
testcase_29 AC 79 ms
75,500 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)
        cnt2 = n - bisect_right(bl, p-a-1)
        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