結果
| 問題 | No.1597 Matrix Sort |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-07-02 02:05:11 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,278 ms / 1,500 ms |
| コード長 | 925 bytes |
| 記録 | |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 152,472 KB |
| 最終ジャッジ日時 | 2026-03-30 05:14:19 |
| 合計ジャッジ時間 | 11,066 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
from bisect import *
from collections import *
N, K, P = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [10 ** 18]
A.sort(reverse=True)
B.sort()
no = -1
yes = P
def check(m):
cnt = 0
Q = deque()
now = 0
for a in A:
while B[now] <= m - a:
Q.append(B[now])
now += 1
while Q:
if Q[0] < -a:
Q.popleft()
else:
break
cnt += len(Q)
Q = deque()
now = 0
for a in A:
while B[now] <= m - a + P:
Q.append(B[now])
now += 1
while Q:
if Q[0] < P - a:
Q.popleft()
else:
break
cnt += len(Q)
return cnt >= K
while yes - no != 1:
mid = (yes + no)//2
if check(mid):
yes = mid
else:
no = mid
print(yes)
rlangevin