結果

問題 No.1597 Matrix Sort
ユーザー zkouzkou
提出日時 2021-07-10 00:12:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 340 ms / 1,500 ms
コード長 627 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 101,944 KB
最終ジャッジ日時 2023-09-14 11:34:07
合計ジャッジ時間 8,387 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,156 KB
testcase_01 AC 70 ms
70,888 KB
testcase_02 AC 71 ms
70,908 KB
testcase_03 AC 320 ms
97,420 KB
testcase_04 AC 340 ms
97,536 KB
testcase_05 AC 334 ms
97,952 KB
testcase_06 AC 324 ms
97,360 KB
testcase_07 AC 311 ms
97,856 KB
testcase_08 AC 285 ms
97,396 KB
testcase_09 AC 284 ms
97,364 KB
testcase_10 AC 151 ms
100,228 KB
testcase_11 AC 210 ms
98,260 KB
testcase_12 AC 244 ms
100,504 KB
testcase_13 AC 302 ms
99,196 KB
testcase_14 AC 310 ms
97,364 KB
testcase_15 AC 206 ms
100,416 KB
testcase_16 AC 245 ms
99,172 KB
testcase_17 AC 265 ms
97,344 KB
testcase_18 AC 327 ms
98,172 KB
testcase_19 AC 265 ms
97,400 KB
testcase_20 AC 250 ms
97,332 KB
testcase_21 AC 233 ms
98,132 KB
testcase_22 AC 225 ms
98,156 KB
testcase_23 AC 167 ms
100,000 KB
testcase_24 AC 128 ms
101,944 KB
testcase_25 AC 113 ms
101,540 KB
testcase_26 AC 71 ms
71,236 KB
testcase_27 AC 73 ms
70,988 KB
testcase_28 AC 73 ms
70,980 KB
testcase_29 AC 73 ms
71,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left, bisect_right

N, K, P = map(int, input().split())
As = sorted(map(int, input().split()))
Bs = sorted(map(int, input().split()))

def isok(m):
    cnt = 0
    p = N
    q = N
    r = N
    for A in As:
        while p > 0 and m - A < Bs[p - 1]:
            p -= 1
        while q > 0 and m - A + P < Bs[q - 1]:
            q -= 1
        while r > 0 and - A + P <= Bs[r - 1]:
            r -= 1
        cnt += p + q - r
    # print(m ,cnt)
    return cnt < K


ok = -1
ng = P
while ng - ok > 1:
    mid = (ok + ng) // 2
    if isok(mid):
        ok = mid
    else:
        ng = mid

print(ok + 1)
0