結果
問題 | No.1950 片道きゃっちぼーる |
ユーザー |
|
提出日時 | 2022-05-21 00:07:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 987 ms / 3,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 145,476 KB |
最終ジャッジ日時 | 2024-09-20 10:31:07 |
合計ジャッジ時間 | 12,465 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#int(input()) #map(int, input().split()) #list(map(int, input().split())) import sys sys.setrecursionlimit(200000) N = int(input()) X = list(map(int, input().split())) A = list(map(int, input().split())) import bisect to = [[] for i in range(N)] for i in range(N): a = X[i] + A[i] d = bisect.bisect_left(X, a) if d < N and X[d] == a: to[d].append(i) a = X[i] - A[i] d = bisect.bisect_left(X, a) if d < N and X[d] == a: to[d].append(i) p = [0] * N for i in range(N): p[i] = [X[i] + A[i], i] p = sorted(p, reverse=True) ans = [0] * N for i in range(N): a = p[i][0] b = p[i][1] if ans[b] != 0: continue q = [b] while q: t = q.pop() ans[t] = a - X[t] for x in to[t]: if ans[x] == 0: q.append(x) for i in range(N): print(ans[i])