結果
| 問題 |
No.1597 Matrix Sort
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:35:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,215 bytes |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 81,664 KB |
| 実行使用メモリ | 116,436 KB |
| 最終ジャッジ日時 | 2025-06-12 21:38:13 |
| 合計ジャッジ時間 | 29,145 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 TLE * 9 |
ソースコード
import bisect
def find_kth_smallest():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
N = int(data[idx])
idx += 1
K = int(data[idx])
idx += 1
P = int(data[idx])
idx += 1
A = list(map(int, data[idx:idx+N]))
idx += N
B = list(map(int, data[idx:idx+N]))
B.sort()
low = 0
high = P - 1
ans = 0
while low <= high:
mid = (low + high) // 2
count = 0
for a in A:
s = a
if mid < s:
low_b = P - s
high_b = mid + (P - s)
high_b = min(high_b, P - 1)
l = bisect.bisect_left(B, low_b)
r = bisect.bisect_right(B, high_b)
cnt = r - l
else:
val1 = mid - s
count1 = bisect.bisect_right(B, val1)
val2 = P - s
pos = bisect.bisect_left(B, val2)
count2 = len(B) - pos
cnt = count1 + count2
count += cnt
if count >= K:
ans = mid
high = mid - 1
else:
low = mid + 1
print(ans)
find_kth_smallest()
gew1fw