結果

問題 No.1597 Matrix Sort
コンテスト
ユーザー marroncastle
提出日時 2021-07-09 22:47:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,301 ms / 1,500 ms
コード長 524 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 200 ms
コンパイル使用メモリ 85,320 KB
実行使用メモリ 112,016 KB
最終ジャッジ日時 2026-03-22 19:37:12
合計ジャッジ時間 22,412 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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