結果

問題 No.1597 Matrix Sort
ユーザー ntudantuda
提出日時 2021-08-09 22:11:43
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 821 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 136,680 KB
最終ジャッジ日時 2023-10-21 19:58:42
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,564 KB
testcase_01 AC 46 ms
61,200 KB
testcase_02 AC 46 ms
61,200 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N,K,P = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A.sort()
B.sort()


dic = {}
dic[-1] = 0
suma = 1
def check_o(n):
    x = bisect.bisect_left(A, n)
    y = bisect.bisect_right(A, n)
    if x != y:
        return x
    else: 
        return x - 1     

A2 = []
for a in A:
    dic[a] = suma
    dic[P + a] = N + suma
    suma += 1
    A2.append(P + a)
A = [-1] + A + A2
#print(A)
#print(dic)

def check(T):
    num = 0
    for b in B:
        x = check_o(P+T-b)
        y = check_o(P-b-1)
        
        num += dic[A[x]] - dic[A[y]]
        #print(b,P+T-b,A[x],P-b-1,A[y])
    #print(T,num)
    return (num < K)

lb = 0 
ub = P
    
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid
print(lb+1)
0