結果

問題 No.1597 Matrix Sort
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-02-06 17:28:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 639 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 265,412 KB
最終ジャッジ日時 2023-09-02 07:02:47
合計ジャッジ時間 4,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,608 KB
testcase_01 AC 19 ms
8,468 KB
testcase_02 AC 19 ms
8,492 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,P = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A.sort()
B.sort()
from collections import Counter
c = Counter(B)
F = [0]*(P+1)
for i in range(1,P):
    F[i+1] = F[i] + c[i]
def is_ok(x):
    tmp = 0
    for a in A:
        if 0<=x-a<=P-1:
            tmp += F[x-a+1] - F[0]
            
        if P-a <= P-1:
            tmp += F[min(P-1,P+x-a)+1] - F[P-a]
        
    return tmp >= K
            
            
y = P-1
x = 0
if is_ok(0):
    print(0)
    exit()
while y-x>1:
    mid = (y+x)//2
    
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
        
    
0