結果
問題 |
No.1950 片道きゃっちぼーる
|
ユーザー |
![]() |
提出日時 | 2022-05-21 14:21:33 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 822 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 367,328 KB |
最終ジャッジ日時 | 2024-09-20 11:46:16 |
合計ジャッジ時間 | 6,516 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 18 |
ソースコード
import sys sys.setrecursionlimit(10 ** 6) import pypyjit pypyjit.set_param('max_unroll_recursion=-1') N = int(input()) X = list(map(int, input().split())) A = list(map(int, input().split())) x2i = {} for i in range(N): x2i[X[i]] = i memo = [0] * N def dfs(p, used): if memo[p] != 0: return memo[p] c = X[p] + A[p] for s in (1, -1): x = X[p] + A[p] * s if x in x2i: j = x2i[x] if used[j]: continue used[j] = True c = max(c, dfs(j, used)) used[j] = False memo[p] = c #print(f'{p=} {c=} X:{c-X[p]}') return memo[p] used = [False] * N for i in range(N): if memo[i] != 0: continue for j in range(N): used[j] = False used[i] = True dfs(i, used) for i in range(N): print(memo[i] - X[i])