結果

問題 No.1597 Matrix Sort
ユーザー ああいいああいい
提出日時 2022-03-15 18:51:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 1,500 ms
コード長 494 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 81,784 KB
実行使用メモリ 244,700 KB
最終ジャッジ日時 2023-10-23 16:50:22
合計ジャッジ時間 11,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,536 KB
testcase_01 AC 36 ms
59,504 KB
testcase_02 AC 36 ms
59,504 KB
testcase_03 AC 266 ms
243,728 KB
testcase_04 AC 290 ms
243,752 KB
testcase_05 AC 323 ms
243,780 KB
testcase_06 AC 328 ms
243,764 KB
testcase_07 AC 281 ms
243,720 KB
testcase_08 AC 241 ms
244,648 KB
testcase_09 AC 269 ms
244,656 KB
testcase_10 AC 216 ms
242,476 KB
testcase_11 AC 222 ms
244,664 KB
testcase_12 AC 93 ms
102,304 KB
testcase_13 AC 131 ms
119,008 KB
testcase_14 AC 296 ms
244,700 KB
testcase_15 AC 105 ms
102,456 KB
testcase_16 AC 130 ms
118,868 KB
testcase_17 AC 255 ms
243,948 KB
testcase_18 AC 283 ms
243,768 KB
testcase_19 AC 250 ms
243,764 KB
testcase_20 AC 236 ms
243,844 KB
testcase_21 AC 236 ms
243,744 KB
testcase_22 AC 235 ms
243,380 KB
testcase_23 AC 218 ms
242,808 KB
testcase_24 AC 72 ms
97,860 KB
testcase_25 AC 70 ms
97,728 KB
testcase_26 AC 34 ms
53,536 KB
testcase_27 AC 35 ms
53,536 KB
testcase_28 AC 34 ms
53,536 KB
testcase_29 AC 141 ms
215,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,P = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))


C = P * 2
S = [0] * (C+1)
for b in B:
    S[b] += 1
for i in range(1,C+1):
    S[i] += S[i-1]

def calc(x):
    ans = 0
    for a in A:
        if a <= x:
            ans += S[x-a]
        ans += S[x+P-a] - S[P-a-1]
    return ans >= K
    
end = P-1
start = -1
while end - start > 1:
    mid = end + start >> 1
    if calc(mid):
        end = mid
    else:
        start = mid
print(end)
0