結果

問題 No.1597 Matrix Sort
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-27 18:07:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,241 ms / 1,500 ms
コード長 529 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 494,504 KB
最終ジャッジ日時 2023-09-12 21:25:59
合計ジャッジ時間 20,571 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,288 KB
testcase_01 AC 71 ms
70,988 KB
testcase_02 AC 70 ms
71,440 KB
testcase_03 AC 1,238 ms
493,788 KB
testcase_04 AC 1,241 ms
493,748 KB
testcase_05 AC 964 ms
493,488 KB
testcase_06 AC 915 ms
493,388 KB
testcase_07 AC 804 ms
493,652 KB
testcase_08 AC 786 ms
494,076 KB
testcase_09 AC 657 ms
494,152 KB
testcase_10 AC 665 ms
487,784 KB
testcase_11 AC 687 ms
494,504 KB
testcase_12 AC 133 ms
102,632 KB
testcase_13 AC 212 ms
185,620 KB
testcase_14 AC 717 ms
494,188 KB
testcase_15 AC 142 ms
102,676 KB
testcase_16 AC 211 ms
185,564 KB
testcase_17 AC 656 ms
494,028 KB
testcase_18 AC 703 ms
493,636 KB
testcase_19 AC 685 ms
493,508 KB
testcase_20 AC 646 ms
493,612 KB
testcase_21 AC 638 ms
493,484 KB
testcase_22 AC 650 ms
493,464 KB
testcase_23 AC 728 ms
487,688 KB
testcase_24 AC 112 ms
101,720 KB
testcase_25 AC 110 ms
101,460 KB
testcase_26 AC 74 ms
71,228 KB
testcase_27 AC 72 ms
71,196 KB
testcase_28 AC 74 ms
71,240 KB
testcase_29 AC 553 ms
479,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ctA = [0]*P
ctB = [0]*P
for a, b in zip(A, B):
    ctA[a] += 1
    ctB[b] += 1

acumB = [0]+list(accumulate(ctB))


def solve(v):
    ct = 0
    for a in A:
        if v >= a:
            ct += acumB[v-a+1]
        ct += acumB[min(P, P+v-a+1)]-acumB[P-a]
    return ct >= K


l, r = -1, P-1
while r-l > 1:
    m = (l+r)//2
    if solve(m):
        r = m
    else:
        l = m

print(r)
0