結果
| 問題 | No.1950 片道きゃっちぼーる |
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-04-08 18:40:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,732 ms / 3,000 ms |
| コード長 | 727 bytes |
| 記録 | |
| コンパイル時間 | 506 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 407,132 KB |
| 最終ジャッジ日時 | 2024-12-21 06:32:30 |
| 合計ジャッジ時間 | 20,632 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
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)
H20