結果

問題 No.1950 片道きゃっちぼーる
コンテスト
ユーザー pitP
提出日時 2022-05-20 22:58:34
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 435 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 223 ms
コンパイル使用メモリ 96,072 KB
実行使用メモリ 227,308 KB
最終ジャッジ日時 2026-08-31 17:25:53
合計ジャッジ時間 18,493 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
import heapq


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]
    heapq.heappush(hq,[-x[i]-a[i] , i])

ans = [0] * n

while hq:
    _,idx = heapq.heappop(hq)
    ans[idx] = max(a[idx] , d[x[idx] + a[idx]] + a[idx] , d[x[idx] - a[idx]] - a[idx])
    d[x[idx]] = ans[idx]

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