結果

問題 No.1950 片道きゃっちぼーる
ユーザー 👑 H20H20
提出日時 2022-04-02 19:57:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,505 ms / 3,000 ms
コード長 531 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 420,412 KB
最終ジャッジ日時 2023-08-23 06:12:10
合計ジャッジ時間 20,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,912 KB
testcase_01 AC 91 ms
71,908 KB
testcase_02 AC 90 ms
71,776 KB
testcase_03 AC 1,356 ms
415,888 KB
testcase_04 AC 1,505 ms
420,412 KB
testcase_05 AC 93 ms
71,688 KB
testcase_06 AC 784 ms
390,984 KB
testcase_07 AC 451 ms
231,836 KB
testcase_08 AC 872 ms
232,112 KB
testcase_09 AC 929 ms
301,680 KB
testcase_10 AC 601 ms
181,996 KB
testcase_11 AC 436 ms
224,612 KB
testcase_12 AC 517 ms
224,472 KB
testcase_13 AC 503 ms
174,236 KB
testcase_14 AC 491 ms
164,836 KB
testcase_15 AC 1,445 ms
365,992 KB
testcase_16 AC 826 ms
312,972 KB
testcase_17 AC 90 ms
71,684 KB
testcase_18 AC 702 ms
218,992 KB
testcase_19 AC 1,291 ms
298,400 KB
testcase_20 AC 454 ms
224,892 KB
testcase_21 AC 431 ms
160,760 KB
testcase_22 AC 435 ms
160,684 KB
権限があれば一括ダウンロードができます

ソースコード

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