結果

問題 No.1597 Matrix Sort
ユーザー mrngmrng
提出日時 2021-12-15 13:51:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 352 ms / 1,500 ms
コード長 413 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 181,228 KB
最終ジャッジ日時 2023-10-01 02:27:33
合計ジャッジ時間 9,907 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,436 KB
testcase_01 AC 70 ms
71,300 KB
testcase_02 AC 71 ms
71,376 KB
testcase_03 AC 293 ms
180,752 KB
testcase_04 AC 302 ms
180,944 KB
testcase_05 AC 333 ms
180,976 KB
testcase_06 AC 352 ms
180,872 KB
testcase_07 AC 278 ms
180,908 KB
testcase_08 AC 269 ms
181,228 KB
testcase_09 AC 281 ms
180,948 KB
testcase_10 AC 193 ms
180,236 KB
testcase_11 AC 206 ms
180,676 KB
testcase_12 AC 144 ms
102,268 KB
testcase_13 AC 185 ms
110,180 KB
testcase_14 AC 315 ms
180,936 KB
testcase_15 AC 149 ms
101,896 KB
testcase_16 AC 165 ms
110,188 KB
testcase_17 AC 254 ms
180,880 KB
testcase_18 AC 301 ms
180,780 KB
testcase_19 AC 239 ms
180,820 KB
testcase_20 AC 221 ms
180,660 KB
testcase_21 AC 219 ms
180,948 KB
testcase_22 AC 215 ms
180,500 KB
testcase_23 AC 195 ms
180,304 KB
testcase_24 AC 112 ms
101,392 KB
testcase_25 AC 105 ms
101,308 KB
testcase_26 AC 71 ms
71,220 KB
testcase_27 AC 70 ms
71,244 KB
testcase_28 AC 72 ms
71,268 KB
testcase_29 AC 129 ms
153,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
n,k,p = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [0]*p
for i in range(n):
	c[b[i]] += 1
for i in range(p-1):
	c[i+1] += c[i]
l,r = -1,p
while r-l>1:
	m = (l+r)//2
	cnt = 0
	for i in range(n):
		cnt += c[min(p-1,m+p-a[i]-1)]-c[p-a[i]-1]
		if m>=a[i]+1: cnt += c[m-a[i]-1]
	if cnt<k: l = m
	else: r = m
print(l)
0