結果

問題 No.1597 Matrix Sort
ユーザー w0mbatw0mbat
提出日時 2021-07-10 09:21:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 100,436 KB
最終ジャッジ日時 2023-09-14 18:42:48
合計ジャッジ時間 31,485 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,296 KB
testcase_01 AC 77 ms
74,992 KB
testcase_02 AC 77 ms
75,140 KB
testcase_03 WA -
testcase_04 AC 1,421 ms
96,952 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,095 ms
97,592 KB
testcase_09 AC 1,176 ms
97,668 KB
testcase_10 AC 958 ms
96,864 KB
testcase_11 AC 415 ms
96,332 KB
testcase_12 AC 849 ms
98,692 KB
testcase_13 AC 1,244 ms
96,080 KB
testcase_14 AC 1,401 ms
97,456 KB
testcase_15 AC 786 ms
99,804 KB
testcase_16 AC 1,192 ms
96,088 KB
testcase_17 TLE -
testcase_18 AC 1,343 ms
97,088 KB
testcase_19 AC 1,321 ms
97,304 KB
testcase_20 TLE -
testcase_21 AC 1,407 ms
97,452 KB
testcase_22 AC 1,368 ms
96,984 KB
testcase_23 TLE -
testcase_24 AC 188 ms
100,436 KB
testcase_25 AC 171 ms
100,380 KB
testcase_26 WA -
testcase_27 AC 72 ms
71,160 KB
testcase_28 AC 72 ms
71,096 KB
testcase_29 AC 80 ms
75,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right
import sys
def main():
    input = sys.stdin.readline
    N, K, P = map(int, input().split())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    A.sort()
    B.sort()

    # x以下の要素の数
    def f(x):
        res = 0
        for a in A:
            # Ai+Bj <= x
            if a + B[0] <= x:
                i = bisect_right(B, x - a)
                res += i
            # P <= Ai+Bi <= P+x
            if a + B[0] <= P + x:
                i = bisect_left(B, P - a)
                j = bisect_right(B, P + x - a)
                res += max(0, j - i)
        return res

    l = 0
    r = P
    while r - l > 1:
        m = (l + r) // 2
        if f(m) < K: l = m
        else: r = m
    print(r)

if __name__ == '__main__':
    main()
0