結果

問題 No.1950 片道きゃっちぼーる
コンテスト
ユーザー H20
提出日時 2022-04-08 18:40:49
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 873 ms / 3,000 ms
コード長 727 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 230 ms
コンパイル使用メモリ 85,160 KB
実行使用メモリ 423,032 KB
最終ジャッジ日時 2026-05-27 23:21:05
合計ジャッジ時間 11,139 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

N = int(input())
X = list(map(int, input().split())) 
A = list(map(int, input().split()))
if 1<=N<=2*10**5 and 1<=min(A) and max(A)<=10**9 and 0<=min(X) and max(X)<=10**9 and len(set(X))==N and X == sorted(X):
    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