結果

問題 No.1597 Matrix Sort
コンテスト
ユーザー Navier_Boltzmann
提出日時 2022-02-06 17:25:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 180,688 KB
最終ジャッジ日時 2024-06-11 13:50:39
合計ジャッジ時間 9,393 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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 = 2*P
x = -1
while y-x>1:
    mid = (y+x)//2
    
    if is_ok(mid):
        y = mid
    else:
        x = mid
print(y)
        
    
0