結果

問題 No.1950 片道きゃっちぼーる
ユーザー lam6er
提出日時 2025-04-16 00:13:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 81,988 KB
実行使用メモリ 135,912 KB
最終ジャッジ日時 2025-04-16 00:14:56
合計ジャッジ時間 7,404 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

n = int(input())
X = list(map(int, input().split()))
A = list(map(int, input().split()))

right = [0] * n
left = [0] * n

# Calculate right array from the end to the beginning
for i in reversed(range(n)):
    pos = X[i] + A[i]
    j = bisect.bisect_left(X, pos)
    if j < n and X[j] == pos:
        right[i] = A[i] + max(right[j], left[j])
    else:
        right[i] = A[i]

# Calculate left array from the beginning to the end
for i in range(n):
    pos = X[i] - A[i]
    j = bisect.bisect_left(X, pos)
    if j < n and X[j] == pos:
        left[i] = -A[i] + max(right[j], left[j])
    else:
        left[i] = -A[i]

# Determine the maximum positive distance for each person
for i in range(n):
    max_dist = max(right[i], left[i])
    print(max(max_dist, 0))
0