結果

問題 No.1597 Matrix Sort
ユーザー rlangevinrlangevin
提出日時 2023-07-02 02:10:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,235 ms / 1,500 ms
コード長 865 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 103,536 KB
最終ジャッジ日時 2023-09-22 21:10:42
合計ジャッジ時間 12,104 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,416 KB
testcase_01 AC 67 ms
71,072 KB
testcase_02 AC 69 ms
71,208 KB
testcase_03 AC 331 ms
98,356 KB
testcase_04 AC 427 ms
98,688 KB
testcase_05 AC 916 ms
98,448 KB
testcase_06 AC 943 ms
98,528 KB
testcase_07 AC 1,235 ms
98,516 KB
testcase_08 AC 276 ms
98,104 KB
testcase_09 AC 398 ms
98,644 KB
testcase_10 AC 253 ms
100,472 KB
testcase_11 AC 183 ms
98,116 KB
testcase_12 AC 257 ms
100,012 KB
testcase_13 AC 375 ms
100,116 KB
testcase_14 AC 505 ms
97,952 KB
testcase_15 AC 209 ms
100,260 KB
testcase_16 AC 260 ms
100,084 KB
testcase_17 AC 288 ms
98,400 KB
testcase_18 AC 593 ms
98,392 KB
testcase_19 AC 684 ms
98,448 KB
testcase_20 AC 409 ms
98,684 KB
testcase_21 AC 256 ms
98,404 KB
testcase_22 AC 275 ms
99,116 KB
testcase_23 AC 272 ms
100,808 KB
testcase_24 AC 135 ms
103,536 KB
testcase_25 AC 122 ms
103,376 KB
testcase_26 AC 69 ms
71,316 KB
testcase_27 AC 69 ms
71,320 KB
testcase_28 AC 70 ms
71,264 KB
testcase_29 AC 70 ms
71,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *

N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [10 ** 18]
A.sort(reverse=True)
B.sort()
no = -1
yes = P

def check(m):
    cnt = 0
    nowR, nowL = 0, 0
    for a in A:
        while B[nowR] <= m - a:
            nowR += 1
        while nowR - nowL:
            if B[nowL] < -a:
                nowL += 1
            else:
                break
        cnt += nowR - nowL
        
    nowR, nowL = 0, 0
    for a in A:
        while B[nowR] <= m - a + P:
            nowR += 1
        while nowR - nowL:
            if B[nowL] < P - a:
                nowL += 1
            else:
                break
        cnt += nowR - nowL
        
    return cnt >= K


while yes - no != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid
print(yes) 
0