結果

問題 No.1597 Matrix Sort
ユーザー penguinmanpenguinman
提出日時 2021-05-05 02:14:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 325 ms / 1,500 ms
コード長 545 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 168,000 KB
最終ジャッジ日時 2023-09-14 06:46:09
合計ジャッジ時間 8,161 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,092 KB
testcase_01 AC 71 ms
71,268 KB
testcase_02 AC 69 ms
71,268 KB
testcase_03 AC 270 ms
167,636 KB
testcase_04 AC 283 ms
167,772 KB
testcase_05 AC 324 ms
168,000 KB
testcase_06 AC 322 ms
167,576 KB
testcase_07 AC 273 ms
167,852 KB
testcase_08 AC 266 ms
167,664 KB
testcase_09 AC 277 ms
167,864 KB
testcase_10 AC 192 ms
167,428 KB
testcase_11 AC 194 ms
167,780 KB
testcase_12 AC 132 ms
102,676 KB
testcase_13 AC 193 ms
100,932 KB
testcase_14 AC 325 ms
167,996 KB
testcase_15 AC 143 ms
103,088 KB
testcase_16 AC 169 ms
100,856 KB
testcase_17 AC 242 ms
167,852 KB
testcase_18 AC 294 ms
167,916 KB
testcase_19 AC 236 ms
167,920 KB
testcase_20 AC 216 ms
167,828 KB
testcase_21 AC 214 ms
167,648 KB
testcase_22 AC 214 ms
167,640 KB
testcase_23 AC 192 ms
167,692 KB
testcase_24 AC 112 ms
101,876 KB
testcase_25 AC 110 ms
102,048 KB
testcase_26 AC 70 ms
71,216 KB
testcase_27 AC 69 ms
71,212 KB
testcase_28 AC 71 ms
71,224 KB
testcase_29 AC 128 ms
153,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,P = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
imos = [0]*(P+1)
for i in range(N):
    imos[B[i]+1] += 1
for i in range(P):
    imos[i+1] += imos[i]
left = -1
right = P
while left+1 < right:
    mid = (left+right)//2
    cnt = 0
    for i in range(N):
        l = -A[i]
        r = mid-A[i]
        if r < 0:
            cnt += imos[r+P+1]-imos[l+P]
        else:
            cnt += imos[r+1]+imos[P]-imos[l+P]
    if cnt >= K:
        right = mid
    else:
        left = mid
print(right)
0