結果

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

ソースコード

diff #
raw source code

import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
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