結果

問題 No.1950 片道きゃっちぼーる
ユーザー noriocnorioc
提出日時 2022-05-21 00:47:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 98,332 KB
最終ジャッジ日時 2023-10-20 15:20:52
合計ジャッジ時間 15,057 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,100 KB
testcase_01 AC 29 ms
10,100 KB
testcase_02 AC 29 ms
10,100 KB
testcase_03 AC 748 ms
98,332 KB
testcase_04 WA -
testcase_05 AC 29 ms
10,100 KB
testcase_06 AC 678 ms
92,136 KB
testcase_07 AC 469 ms
50,848 KB
testcase_08 AC 547 ms
50,916 KB
testcase_09 WA -
testcase_10 AC 614 ms
49,876 KB
testcase_11 AC 613 ms
49,180 KB
testcase_12 AC 603 ms
49,876 KB
testcase_13 AC 634 ms
45,028 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 725 ms
66,292 KB
testcase_17 AC 29 ms
10,100 KB
testcase_18 AC 588 ms
46,620 KB
testcase_19 WA -
testcase_20 AC 525 ms
50,920 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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):
    if memo[p] != 0: return memo[p]

    memo[p] = X[p] + A[p]
    for s in (1, -1):
        x = X[p] + A[p] * s
        if x in x2i:
            j = x2i[x]
            memo[p] = max(memo[p], dfs(j))
    return memo[p]


for i in range(N):
    dfs(i)

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