結果

問題 No.1950 片道きゃっちぼーる
ユーザー ああいい
提出日時 2022-05-20 22:04:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 576 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 171,176 KB
最終ジャッジ日時 2024-09-20 08:13:35
合計ジャッジ時間 9,178 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

d = dict()
for i,x in enumerate(X):
    d[x] = i
G = [[] for _ in range(N)]
for i in range(N):
    x = X[i]
    a = A[i]
    if x + a in d:
        G[d[x + a]].append(i)
    if x - a in d:
        G[d[x - a]].append(i)
dp = [X[i] + A[i] for i in range(N)]
top = [(X[i],A[i],i) for i in range(N)]
top.sort(key = lambda x:x[0] + x[1],reverse = True)
for x,a,i in top:
    for j in G[i]:
        if dp[i] > dp[j]:
            dp[j] = dp[i]
for i in range(N):
    print(dp[i] - X[i])
       
0