結果

問題 No.1597 Matrix Sort
ユーザー marroncastle
提出日時 2021-07-09 22:47:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 524 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 105,600 KB
最終ジャッジ日時 2024-07-01 17:59:59
合計ジャッジ時間 30,343 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from bisect import *
def check(target):
    cnt = 0
    for i in range(N):
        t = target - A[i]
        if t >= 0: cnt += bisect_right(B, t)
        cnt += bisect_right(B, t+P) - bisect_right(B, P-1-A[i])
    return cnt >= K

low,high = -1,P-1
mid = (low+high)//2
while high-low>1:
    if check(mid):
        high = mid
    else:
        low = mid
    mid = (low+high)//2
ans = high
print(ans)
0