結果

問題 No.1597 Matrix Sort
ユーザー IgrmiIgrmi
提出日時 2021-07-09 23:15:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 283 ms / 1,500 ms
コード長 572 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 104,184 KB
最終ジャッジ日時 2023-09-14 10:45:26
合計ジャッジ時間 7,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,216 KB
testcase_01 AC 72 ms
71,156 KB
testcase_02 AC 71 ms
71,084 KB
testcase_03 AC 271 ms
99,876 KB
testcase_04 AC 282 ms
100,008 KB
testcase_05 AC 283 ms
99,848 KB
testcase_06 AC 278 ms
100,004 KB
testcase_07 AC 272 ms
99,976 KB
testcase_08 AC 218 ms
99,612 KB
testcase_09 AC 227 ms
99,784 KB
testcase_10 AC 205 ms
101,296 KB
testcase_11 AC 174 ms
100,472 KB
testcase_12 AC 218 ms
101,268 KB
testcase_13 AC 263 ms
101,328 KB
testcase_14 AC 275 ms
99,992 KB
testcase_15 AC 193 ms
101,680 KB
testcase_16 AC 228 ms
101,400 KB
testcase_17 AC 237 ms
99,940 KB
testcase_18 AC 282 ms
100,216 KB
testcase_19 AC 245 ms
100,160 KB
testcase_20 AC 235 ms
99,612 KB
testcase_21 AC 224 ms
100,440 KB
testcase_22 AC 209 ms
100,528 KB
testcase_23 AC 235 ms
102,092 KB
testcase_24 AC 132 ms
104,184 KB
testcase_25 AC 115 ms
103,604 KB
testcase_26 AC 71 ms
71,424 KB
testcase_27 AC 70 ms
71,632 KB
testcase_28 AC 70 ms
71,308 KB
testcase_29 AC 71 ms
70,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K, P = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)
B = sorted(list(map(int, input().split())))
LTP = 0  # less than P
j = 0
for i in range(N):
    while j < N and A[i] + B[j] < P: j += 1
    LTP += j

L = 0
R = P - 1
while L != R:
    M = (L + R) // 2
    Count = -LTP
    j = 0
    for i in range(N):
        while j < N and A[i] + B[j] <= M: j += 1
        Count += j
    j = 0
    for i in range(N):
        while j < N and A[i] + B[j] <= M + P: j += 1
        Count += j
    if Count < K: L = M + 1
    else: R = M
print(L)
0