結果

問題 No.1950 片道きゃっちぼーる
ユーザー noriocnorioc
提出日時 2022-05-21 13:37:08
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 634 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 536,908 KB
最終ジャッジ日時 2023-10-20 16:09:05
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 38 ms
53,396 KB
testcase_02 AC 38 ms
53,396 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 6)

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
    return memo[p]


for i in range(N):
    used = [False] * N
    dfs(i, used)

for i in range(N):
    print(memo[i] - X[i])
0