結果

問題 No.1597 Matrix Sort
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-02-06 17:31:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 185,700 KB
最終ジャッジ日時 2023-09-02 07:03:10
合計ジャッジ時間 12,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,692 KB
testcase_01 AC 94 ms
71,472 KB
testcase_02 AC 95 ms
71,708 KB
testcase_03 AC 491 ms
184,888 KB
testcase_04 AC 565 ms
184,736 KB
testcase_05 AC 545 ms
185,100 KB
testcase_06 AC 534 ms
185,092 KB
testcase_07 AC 529 ms
185,148 KB
testcase_08 AC 486 ms
185,700 KB
testcase_09 AC 487 ms
185,524 KB
testcase_10 AC 289 ms
167,924 KB
testcase_11 AC 300 ms
169,316 KB
testcase_12 AC 206 ms
102,764 KB
testcase_13 AC 264 ms
113,840 KB
testcase_14 AC 544 ms
185,584 KB
testcase_15 AC 197 ms
103,032 KB
testcase_16 AC 229 ms
101,040 KB
testcase_17 AC 406 ms
180,620 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 375 ms
170,244 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 144 ms
102,244 KB
testcase_25 AC 136 ms
102,460 KB
testcase_26 AC 92 ms
71,500 KB
testcase_27 AC 92 ms
71,676 KB
testcase_28 AC 91 ms
71,600 KB
testcase_29 AC 237 ms
155,172 KB
権限があれば一括ダウンロードができます

ソースコード

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
if P == 1:
    print(0)
    exit()
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