結果

問題 No.1597 Matrix Sort
ユーザー marroncastlemarroncastle
提出日時 2021-07-09 22:47:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 524 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 103,732 KB
最終ジャッジ日時 2023-09-14 10:27:40
合計ジャッジ時間 32,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,528 KB
testcase_01 AC 77 ms
75,380 KB
testcase_02 AC 77 ms
75,456 KB
testcase_03 AC 1,302 ms
100,040 KB
testcase_04 AC 1,403 ms
100,144 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,077 ms
99,852 KB
testcase_09 TLE -
testcase_10 AC 1,118 ms
101,468 KB
testcase_11 AC 986 ms
100,380 KB
testcase_12 AC 882 ms
101,308 KB
testcase_13 AC 1,240 ms
101,496 KB
testcase_14 TLE -
testcase_15 AC 987 ms
101,424 KB
testcase_16 AC 1,487 ms
101,296 KB
testcase_17 TLE -
testcase_18 AC 1,401 ms
100,080 KB
testcase_19 AC 1,346 ms
100,044 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 AC 202 ms
103,732 KB
testcase_25 AC 187 ms
103,188 KB
testcase_26 AC 69 ms
71,232 KB
testcase_27 AC 71 ms
71,548 KB
testcase_28 AC 70 ms
71,520 KB
testcase_29 AC 78 ms
75,524 KB
権限があれば一括ダウンロードができます

ソースコード

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