結果

問題 No.1597 Matrix Sort
ユーザー w0mbatw0mbat
提出日時 2021-07-09 22:18:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 100,536 KB
最終ジャッジ日時 2023-09-14 09:34:25
合計ジャッジ時間 29,966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,344 KB
testcase_01 AC 81 ms
75,084 KB
testcase_02 AC 80 ms
75,264 KB
testcase_03 WA -
testcase_04 AC 1,413 ms
97,300 KB
testcase_05 AC 1,496 ms
97,264 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,075 ms
97,636 KB
testcase_09 AC 1,134 ms
97,640 KB
testcase_10 AC 927 ms
97,032 KB
testcase_11 AC 422 ms
96,340 KB
testcase_12 AC 860 ms
98,904 KB
testcase_13 AC 1,256 ms
96,256 KB
testcase_14 AC 1,438 ms
97,772 KB
testcase_15 AC 784 ms
100,028 KB
testcase_16 AC 1,166 ms
96,060 KB
testcase_17 TLE -
testcase_18 AC 1,353 ms
97,348 KB
testcase_19 AC 1,323 ms
97,400 KB
testcase_20 TLE -
testcase_21 AC 1,344 ms
97,376 KB
testcase_22 AC 1,332 ms
97,160 KB
testcase_23 TLE -
testcase_24 AC 190 ms
100,476 KB
testcase_25 AC 171 ms
100,536 KB
testcase_26 WA -
testcase_27 AC 71 ms
71,232 KB
testcase_28 AC 71 ms
71,260 KB
testcase_29 AC 78 ms
75,356 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