結果

問題 No.1597 Matrix Sort
ユーザー mrngmrng
提出日時 2021-12-14 00:05:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 542 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 75,200 KB
最終ジャッジ日時 2023-09-30 06:05:17
合計ジャッジ時間 6,294 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,024 KB
testcase_01 AC 75 ms
75,200 KB
testcase_02 AC 76 ms
75,176 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 #

def lower_bound(a,x):
	ng,ok = -1,len(a)
	while ok-ng>1:
		m = (ng+ok)//2
		if x<=a[m]: ok = m
		else: ng = m
	return ok

def upper_bound(a,x):
	ok,ng = -1,len(a)
	while ng-ok>1:
		m = (ng+ok)//2
		if x>a[m]: ok = m
		else: ng = m
	return ok

n,k,p = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()
l,r = -1,p
while r-l>1:
	m = (l+r)//2
	cnt = 0
	for i in range(n):
		cnt += upper_bound(b,m+p-a[i])-lower_bound(b,p-a[i])+1+upper_bound(b,m-a[i])+1
	if cnt<k: l = m
	else: r = m
print(l)
0