結果

問題 No.1950 片道きゃっちぼーる
ユーザー lam6er
提出日時 2025-03-31 17:52:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,912 KB
実行使用メモリ 134,576 KB
最終ジャッジ日時 2025-03-31 17:53:20
合計ジャッジ時間 9,884 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

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

sum_r = [0] * n

# Calculate sum_r from right to left
for i in range(n-1, -1, -1):
    target = X[i] + A[i]
    idx = bisect.bisect_left(X, target)
    if idx < len(X) and X[idx] == target:
        sum_r[i] = A[i] + sum_r[idx]
    else:
        sum_r[i] = A[i]

# Calculate the answer for each i
for i in range(n):
    current_max = sum_r[i]
    target_left = X[i] - A[i]
    idx = bisect.bisect_left(X, target_left)
    if idx < len(X) and X[idx] == target_left:
        candidate = sum_r[idx] - A[i]
        if candidate > current_max:
            current_max = candidate
    print(current_max)
0