結果
問題 | No.1950 片道きゃっちぼーる |
ユーザー | mkawa2 |
提出日時 | 2022-05-20 21:46:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 674 ms / 3,000 ms |
コード長 | 1,406 bytes |
コンパイル時間 | 1,279 ms |
コンパイル使用メモリ | 81,736 KB |
実行使用メモリ | 182,288 KB |
最終ジャッジ日時 | 2023-10-20 12:14:48 |
合計ジャッジ時間 | 10,130 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,488 KB |
testcase_01 | AC | 37 ms
53,488 KB |
testcase_02 | AC | 38 ms
53,488 KB |
testcase_03 | AC | 304 ms
160,636 KB |
testcase_04 | AC | 354 ms
161,248 KB |
testcase_05 | AC | 37 ms
53,488 KB |
testcase_06 | AC | 273 ms
177,412 KB |
testcase_07 | AC | 267 ms
171,520 KB |
testcase_08 | AC | 567 ms
169,352 KB |
testcase_09 | AC | 311 ms
159,640 KB |
testcase_10 | AC | 388 ms
179,552 KB |
testcase_11 | AC | 319 ms
182,288 KB |
testcase_12 | AC | 335 ms
180,968 KB |
testcase_13 | AC | 388 ms
152,808 KB |
testcase_14 | AC | 366 ms
158,504 KB |
testcase_15 | AC | 674 ms
170,140 KB |
testcase_16 | AC | 264 ms
159,908 KB |
testcase_17 | AC | 38 ms
53,488 KB |
testcase_18 | AC | 380 ms
160,580 KB |
testcase_19 | AC | 657 ms
170,136 KB |
testcase_20 | AC | 299 ms
169,084 KB |
testcase_21 | AC | 350 ms
164,856 KB |
testcase_22 | AC | 351 ms
164,860 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 n = II() xx = LI() aa = LI() um = [] ux = [] xtou = {} for u, (x, a) in enumerate(zip(xx, aa)): mx = x+a um.append((u, mx)) ux.append((u, x)) xtou[x] = u r = -1 to = [[] for _ in range(n)] for u,x in enumerate(xx): y=x+aa[u] if y in xtou: v=xtou[y] to[v].append(u) y=x-aa[u] if y in xtou: v=xtou[y] to[v].append(u) um.sort(key=lambda x: -x[1]) ans = [-1]*n for u, mx in um: if ans[u] != -1: continue st = [u] ans[u] = mx-xx[u] while st: u = st.pop() for v in to[u]: if ans[v] != -1: continue ans[v] = mx-xx[v] st.append(v) for a in ans: print(a)