結果

問題 No.1597 Matrix Sort
ユーザー rlangevinrlangevin
提出日時 2023-07-02 02:05:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 925 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 151,184 KB
最終ジャッジ日時 2023-09-22 21:05:20
合計ジャッジ時間 18,491 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,224 KB
testcase_01 AC 92 ms
71,548 KB
testcase_02 AC 92 ms
71,556 KB
testcase_03 AC 451 ms
108,632 KB
testcase_04 AC 569 ms
108,948 KB
testcase_05 AC 1,275 ms
141,636 KB
testcase_06 AC 1,312 ms
147,540 KB
testcase_07 TLE -
testcase_08 AC 375 ms
111,288 KB
testcase_09 AC 545 ms
111,004 KB
testcase_10 AC 355 ms
108,628 KB
testcase_11 AC 230 ms
109,432 KB
testcase_12 AC 354 ms
106,268 KB
testcase_13 AC 521 ms
107,832 KB
testcase_14 AC 696 ms
114,756 KB
testcase_15 AC 289 ms
107,156 KB
testcase_16 AC 370 ms
108,836 KB
testcase_17 AC 409 ms
109,440 KB
testcase_18 AC 792 ms
108,932 KB
testcase_19 AC 914 ms
112,912 KB
testcase_20 AC 567 ms
108,404 KB
testcase_21 AC 377 ms
109,544 KB
testcase_22 AC 392 ms
109,324 KB
testcase_23 AC 404 ms
112,600 KB
testcase_24 AC 172 ms
105,344 KB
testcase_25 AC 154 ms
104,092 KB
testcase_26 AC 92 ms
71,648 KB
testcase_27 AC 91 ms
71,404 KB
testcase_28 AC 92 ms
71,692 KB
testcase_29 AC 92 ms
71,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
from collections 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
    Q = deque()
    now = 0
    for a in A:
        while B[now] <= m - a:
            Q.append(B[now])
            now += 1
        while Q:
            if Q[0] < -a:
                Q.popleft()
            else:
                break
        cnt += len(Q)
        
    Q = deque()
    now = 0
    for a in A:
        while B[now] <= m - a + P:
            Q.append(B[now])
            now += 1
        while Q:
            if Q[0] < P - a:
                Q.popleft()
            else:
                break
        cnt += len(Q)
        
    return cnt >= K


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