結果

問題 No.1950 片道きゃっちぼーる
ユーザー pitP
提出日時 2022-05-21 13:42:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 211,728 KB
最終ジャッジ日時 2024-09-20 11:43:52
合計ジャッジ時間 17,869 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


n = int(input())
x = list(map(int,input().split()))
a = list(map(int,input().split()))
d = defaultdict(int)
hq = []

for i in range(n):
    d[x[i]] = a[i]
    hq.append([-x[i]-a[i] , i])
    hq.append([-x[i]+a[i] , i])

ans = [0] * n
hq.sort()

for j in range(2*n):
    dist,i = hq[j]
    ans[i] = max(a[i] , d[x[i] + a[i]] + a[i] , d[x[i] - a[i]] - a[i],ans[i])
    d[x[i]] = max(d[x[i]],ans[i])

print(*ans,sep="\n")
0