結果

問題 No.1597 Matrix Sort
ユーザー Tomii9273Tomii9273
提出日時 2021-07-10 04:08:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 674 ms / 1,500 ms
コード長 677 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 477,696 KB
最終ジャッジ日時 2023-09-14 16:25:14
合計ジャッジ時間 12,920 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,164 KB
testcase_01 AC 75 ms
75,468 KB
testcase_02 AC 76 ms
75,684 KB
testcase_03 AC 637 ms
476,084 KB
testcase_04 AC 674 ms
476,812 KB
testcase_05 AC 554 ms
477,696 KB
testcase_06 AC 546 ms
476,844 KB
testcase_07 AC 560 ms
477,092 KB
testcase_08 AC 506 ms
477,392 KB
testcase_09 AC 517 ms
477,656 KB
testcase_10 AC 443 ms
476,628 KB
testcase_11 AC 454 ms
477,464 KB
testcase_12 AC 127 ms
102,700 KB
testcase_13 AC 186 ms
129,668 KB
testcase_14 AC 549 ms
477,256 KB
testcase_15 AC 127 ms
103,184 KB
testcase_16 AC 159 ms
130,372 KB
testcase_17 AC 465 ms
476,972 KB
testcase_18 AC 531 ms
477,000 KB
testcase_19 AC 511 ms
476,844 KB
testcase_20 AC 459 ms
477,016 KB
testcase_21 AC 452 ms
477,012 KB
testcase_22 AC 453 ms
476,768 KB
testcase_23 AC 459 ms
476,872 KB
testcase_24 AC 120 ms
101,808 KB
testcase_25 AC 116 ms
101,736 KB
testcase_26 AC 70 ms
71,304 KB
testcase_27 AC 71 ms
71,164 KB
testcase_28 AC 70 ms
70,980 KB
testcase_29 AC 382 ms
466,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
# sys.setrecursionlimit(10 ** 9)  # Codeforcesでは350000程度に
def input(): return sys.stdin.readline().strip()


n, k, p = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AN = [0] * p
for i in range(n):
    AN[A[i]] += 1
AN = [0] + AN + AN
for i in range(len(AN)-1):
    AN[i+1] += AN[i]
# print(AN)

ok = p
ng = -1
while abs(ok - ng) > 1:
    mi = (ok + ng) // 2
    cnt = 0
    for i in range(n):
        l = p - B[i] if B[i] != 0 else 0
        r = l + mi
        # print("l,r", l, r)
        cnt += AN[r+1] - AN[l]
    # print(mi, cnt)
    if cnt >= k:
        ok = mi
    else:
        ng = mi
print(ok)
0