結果
| 問題 | 
                            No.1950 片道きゃっちぼーる
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-16 16:39:55 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 776 bytes | 
| コンパイル時間 | 496 ms | 
| コンパイル使用メモリ | 81,656 KB | 
| 実行使用メモリ | 135,456 KB | 
| 最終ジャッジ日時 | 2025-04-16 16:41:16 | 
| 合計ジャッジ時間 | 7,821 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 WA * 4 | 
ソースコード
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))
            
            
            
        
            
lam6er