結果

問題 No.1597 Matrix Sort
ユーザー w0mbatw0mbat
提出日時 2021-07-10 09:39:28
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 820 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 100,400 KB
最終ジャッジ日時 2023-09-14 18:44:54
合計ジャッジ時間 29,227 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,272 KB
testcase_01 AC 76 ms
75,156 KB
testcase_02 AC 77 ms
75,548 KB
testcase_03 AC 1,318 ms
97,240 KB
testcase_04 AC 1,397 ms
97,236 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 999 ms
97,484 KB
testcase_09 AC 1,135 ms
97,544 KB
testcase_10 AC 912 ms
96,800 KB
testcase_11 AC 413 ms
95,988 KB
testcase_12 AC 843 ms
98,576 KB
testcase_13 AC 1,226 ms
96,260 KB
testcase_14 AC 1,371 ms
97,528 KB
testcase_15 AC 777 ms
99,816 KB
testcase_16 AC 1,157 ms
95,880 KB
testcase_17 TLE -
testcase_18 AC 1,477 ms
97,116 KB
testcase_19 AC 1,342 ms
96,976 KB
testcase_20 TLE -
testcase_21 AC 1,198 ms
97,416 KB
testcase_22 AC 1,340 ms
96,836 KB
testcase_23 AC 1,458 ms
95,900 KB
testcase_24 AC 177 ms
100,396 KB
testcase_25 AC 146 ms
100,400 KB
testcase_26 AC 74 ms
71,088 KB
testcase_27 AC 72 ms
71,180 KB
testcase_28 AC 71 ms
71,404 KB
testcase_29 AC 78 ms
75,308 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 = -1
    r = P-1
    while r - l > 1:
        m = (l + r) // 2
        if f(m) < K: l = m
        else: r = m
    print(r)

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