結果

問題 No.1597 Matrix Sort
ユーザー penguinmanpenguinman
提出日時 2021-05-05 02:15:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 1,500 ms
コード長 547 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 168,228 KB
最終ジャッジ日時 2023-09-14 06:47:13
合計ジャッジ時間 7,307 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,568 KB
testcase_01 AC 68 ms
71,476 KB
testcase_02 AC 68 ms
71,564 KB
testcase_03 AC 255 ms
167,980 KB
testcase_04 AC 266 ms
168,184 KB
testcase_05 AC 295 ms
168,124 KB
testcase_06 AC 300 ms
168,200 KB
testcase_07 AC 256 ms
168,064 KB
testcase_08 AC 248 ms
168,004 KB
testcase_09 AC 245 ms
168,088 KB
testcase_10 AC 185 ms
167,908 KB
testcase_11 AC 186 ms
167,960 KB
testcase_12 AC 127 ms
102,996 KB
testcase_13 AC 164 ms
101,152 KB
testcase_14 AC 283 ms
168,156 KB
testcase_15 AC 139 ms
103,436 KB
testcase_16 AC 162 ms
101,220 KB
testcase_17 AC 227 ms
168,228 KB
testcase_18 AC 273 ms
168,052 KB
testcase_19 AC 226 ms
168,028 KB
testcase_20 AC 212 ms
168,204 KB
testcase_21 AC 210 ms
168,180 KB
testcase_22 AC 211 ms
167,960 KB
testcase_23 AC 191 ms
167,860 KB
testcase_24 AC 106 ms
102,260 KB
testcase_25 AC 101 ms
101,996 KB
testcase_26 AC 68 ms
71,332 KB
testcase_27 AC 67 ms
71,156 KB
testcase_28 AC 69 ms
71,380 KB
testcase_29 AC 123 ms
153,780 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-1
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