結果

問題 No.1950 片道きゃっちぼーる
ユーザー H20
提出日時 2022-04-02 19:57:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,422 ms / 3,000 ms
コード長 531 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 410,016 KB
最終ジャッジ日時 2024-12-21 06:31:47
合計ジャッジ時間 18,313 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import sys
sys.setrecursionlimit(10**6)

N = int(input())
X = list(map(int, input().split())) 
A = list(map(int, input().split())) 
L = collections.defaultdict(list)
T = collections.defaultdict(int)
G = []
for i in range(N):
    G.append(X[i]+A[i])
    L[X[i]+A[i]].append(X[i])
    L[X[i]-A[i]].append(X[i])
G.sort(reverse=True)
def dfs(x,v):
    for l in L[x]:
        if T[l]==0:
            T[l]=v
            dfs(l,v)
for g in G:
    if T[g]==0:
        T[g]=g
        dfs(g,g)
for x in X:
    print(T[x]-x)
0