結果

問題 No.1597 Matrix Sort
ユーザー realDivineJKrealDivineJK
提出日時 2021-07-25 17:31:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 718 ms / 1,500 ms
コード長 1,086 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 103,368 KB
最終ジャッジ日時 2023-09-28 07:25:58
合計ジャッジ時間 16,097 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,416 KB
testcase_01 AC 66 ms
71,484 KB
testcase_02 AC 61 ms
71,248 KB
testcase_03 AC 558 ms
99,460 KB
testcase_04 AC 596 ms
99,488 KB
testcase_05 AC 700 ms
99,608 KB
testcase_06 AC 700 ms
99,700 KB
testcase_07 AC 718 ms
99,556 KB
testcase_08 AC 371 ms
99,520 KB
testcase_09 AC 435 ms
99,684 KB
testcase_10 AC 420 ms
100,872 KB
testcase_11 AC 206 ms
99,636 KB
testcase_12 AC 386 ms
103,148 KB
testcase_13 AC 539 ms
101,164 KB
testcase_14 AC 634 ms
99,676 KB
testcase_15 AC 369 ms
103,184 KB
testcase_16 AC 517 ms
101,232 KB
testcase_17 AC 588 ms
99,588 KB
testcase_18 AC 608 ms
99,700 KB
testcase_19 AC 582 ms
99,600 KB
testcase_20 AC 563 ms
99,720 KB
testcase_21 AC 564 ms
99,588 KB
testcase_22 AC 567 ms
100,176 KB
testcase_23 AC 599 ms
100,704 KB
testcase_24 AC 137 ms
103,368 KB
testcase_25 AC 111 ms
102,908 KB
testcase_26 AC 62 ms
71,248 KB
testcase_27 AC 61 ms
71,600 KB
testcase_28 AC 64 ms
71,416 KB
testcase_29 AC 71 ms
76,156 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()
X = [0]*N
for i in range(N):
    l, r = 0, N
    d = N // 2
    if A[i] + B[0] >= P:
        continue
    while r - l > 1:
        if A[i] + B[d] < P:
            l = d
        else:
            r = d
        d = (l + r) // 2
    X[i] = d + 1
L, R = 0, P
D = P // 2
while R - L > 1:
    cnt = 0
    for i in range(N):
        if A[i] + B[0] < D:
            l, r = 0, N
            d = N // 2
            while r - l > 1:
                if A[i] + B[d] < D:
                    l = d
                else:
                    r = d
                d = (l + r) // 2
            cnt += d + 1
        if A[i] + B[0] < D + P:
            l, r = 0, N
            d = N // 2
            while r - l > 1:
                if A[i] + B[d] < D + P:
                    l = d
                else:
                    r = d
                d = (l + r) // 2
            cnt += d + 1 - X[i]
    if cnt < K:
        L = D
    else:
        R = D
    D = (L + R) // 2
print(D)
0