結果

問題 No.1597 Matrix Sort
ユーザー tassei903tassei903
提出日時 2021-07-09 22:36:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 1,500 ms
コード長 774 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 110,992 KB
最終ジャッジ日時 2023-09-14 09:56:23
合計ジャッジ時間 8,387 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,628 KB
testcase_01 AC 71 ms
71,600 KB
testcase_02 AC 72 ms
71,308 KB
testcase_03 AC 290 ms
101,728 KB
testcase_04 AC 331 ms
102,448 KB
testcase_05 AC 322 ms
102,244 KB
testcase_06 AC 318 ms
102,296 KB
testcase_07 AC 318 ms
102,544 KB
testcase_08 AC 295 ms
102,124 KB
testcase_09 AC 310 ms
102,732 KB
testcase_10 AC 228 ms
103,216 KB
testcase_11 AC 180 ms
103,268 KB
testcase_12 AC 219 ms
103,200 KB
testcase_13 AC 271 ms
103,912 KB
testcase_14 AC 287 ms
102,604 KB
testcase_15 AC 193 ms
103,284 KB
testcase_16 AC 231 ms
103,424 KB
testcase_17 AC 267 ms
102,516 KB
testcase_18 AC 301 ms
102,316 KB
testcase_19 AC 275 ms
102,420 KB
testcase_20 AC 235 ms
102,616 KB
testcase_21 AC 229 ms
102,348 KB
testcase_22 AC 250 ms
102,552 KB
testcase_23 AC 242 ms
104,612 KB
testcase_24 AC 132 ms
110,992 KB
testcase_25 AC 122 ms
110,456 KB
testcase_26 AC 72 ms
71,420 KB
testcase_27 AC 73 ms
71,536 KB
testcase_28 AC 72 ms
71,324 KB
testcase_29 AC 72 ms
71,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
#######################################################################

N, K, P = na()

A = sorted(na())[::-1]
B = sorted(na())
B = B+[i+P for i in B]+[10*P]


def f(x):
    l = -1
    r = -1
    res = 0
    for i in range(N):
        while B[l+1]<=P-A[i]-1:
            l+=1
        while B[r+1]<=P+x-A[i]:
            r+=1
        res+=r-l
        #print(x,r,l)
    #print(x,res)
    return res>=K


ok = P-1
ng = -1
while ok-ng>1:
    d = (ok+ng)//2
    if f(d):
        ok = d
    else:
        ng = d

print(ok)
0