結果
問題 |
No.1950 片道きゃっちぼーる
|
ユーザー |
![]() |
提出日時 | 2025-04-16 00:11:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 776 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 82,484 KB |
実行使用メモリ | 135,772 KB |
最終ジャッジ日時 | 2025-04-16 00:13:14 |
合計ジャッジ時間 | 7,895 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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))