結果

問題 No.1597 Matrix Sort
ユーザー w0mbatw0mbat
提出日時 2021-07-10 09:29:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 172,584 KB
最終ジャッジ日時 2023-09-14 18:43:17
合計ジャッジ時間 7,875 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,428 KB
testcase_01 AC 67 ms
71,332 KB
testcase_02 AC 69 ms
71,108 KB
testcase_03 WA -
testcase_04 AC 331 ms
172,376 KB
testcase_05 AC 291 ms
172,224 KB
testcase_06 AC 284 ms
172,220 KB
testcase_07 AC 283 ms
172,284 KB
testcase_08 AC 301 ms
172,544 KB
testcase_09 AC 265 ms
172,488 KB
testcase_10 AC 194 ms
170,016 KB
testcase_11 AC 204 ms
171,068 KB
testcase_12 AC 170 ms
100,172 KB
testcase_13 AC 188 ms
100,996 KB
testcase_14 AC 318 ms
172,412 KB
testcase_15 AC 156 ms
101,056 KB
testcase_16 AC 179 ms
101,312 KB
testcase_17 AC 236 ms
172,008 KB
testcase_18 AC 294 ms
172,104 KB
testcase_19 AC 253 ms
172,376 KB
testcase_20 AC 233 ms
172,348 KB
testcase_21 AC 226 ms
172,584 KB
testcase_22 AC 219 ms
171,768 KB
testcase_23 AC 214 ms
171,204 KB
testcase_24 AC 124 ms
101,792 KB
testcase_25 AC 114 ms
101,752 KB
testcase_26 WA -
testcase_27 AC 72 ms
71,324 KB
testcase_28 AC 74 ms
71,240 KB
testcase_29 AC 128 ms
153,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
    C = [0] * (P)
    for b in B:
        C[b] += 1
    for i in range(1, P):
        C[i] += C[i - 1]

    # x以下の要素の数
    def f(x):
        res = 0
        for a in A:
            # Ai+Bj <= x
            if x - a >= 0:
                res += C[x - a]
            # P <= Ai+Bi <= P+x
            res += C[min(P - 1, P + x - a)] - C[P - a - 1]
        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