結果

問題 No.1597 Matrix Sort
ユーザー marroncastlemarroncastle
提出日時 2021-07-10 00:09:18
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 613 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 103,328 KB
最終ジャッジ日時 2023-09-14 11:32:15
合計ジャッジ時間 32,456 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,144 KB
testcase_01 AC 76 ms
75,452 KB
testcase_02 AC 74 ms
75,180 KB
testcase_03 AC 1,308 ms
98,632 KB
testcase_04 AC 1,403 ms
98,600 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,090 ms
98,384 KB
testcase_09 TLE -
testcase_10 AC 1,054 ms
100,204 KB
testcase_11 AC 997 ms
98,892 KB
testcase_12 AC 901 ms
100,416 KB
testcase_13 AC 1,243 ms
100,016 KB
testcase_14 TLE -
testcase_15 AC 981 ms
100,872 KB
testcase_16 AC 1,451 ms
99,904 KB
testcase_17 TLE -
testcase_18 AC 1,417 ms
98,560 KB
testcase_19 AC 1,368 ms
98,632 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 207 ms
103,328 KB
testcase_25 AC 190 ms
103,084 KB
testcase_26 AC 74 ms
71,344 KB
testcase_27 AC 72 ms
71,416 KB
testcase_28 AC 74 ms
71,284 KB
testcase_29 AC 78 ms
75,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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