結果
| 問題 |
No.1597 Matrix Sort
|
| コンテスト | |
| ユーザー |
realDivineJK
|
| 提出日時 | 2021-07-25 17:31:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 774 ms / 1,500 ms |
| コード長 | 1,086 bytes |
| コンパイル時間 | 161 ms |
| コンパイル使用メモリ | 82,600 KB |
| 実行使用メモリ | 104,684 KB |
| 最終ジャッジ日時 | 2024-07-21 01:52:12 |
| 合計ジャッジ時間 | 14,929 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
X = [0]*N
for i in range(N):
l, r = 0, N
d = N // 2
if A[i] + B[0] >= P:
continue
while r - l > 1:
if A[i] + B[d] < P:
l = d
else:
r = d
d = (l + r) // 2
X[i] = d + 1
L, R = 0, P
D = P // 2
while R - L > 1:
cnt = 0
for i in range(N):
if A[i] + B[0] < D:
l, r = 0, N
d = N // 2
while r - l > 1:
if A[i] + B[d] < D:
l = d
else:
r = d
d = (l + r) // 2
cnt += d + 1
if A[i] + B[0] < D + P:
l, r = 0, N
d = N // 2
while r - l > 1:
if A[i] + B[d] < D + P:
l = d
else:
r = d
d = (l + r) // 2
cnt += d + 1 - X[i]
if cnt < K:
L = D
else:
R = D
D = (L + R) // 2
print(D)
realDivineJK