結果

問題 No.45 回転寿司
ユーザー MitI_7
提出日時 2017-01-11 23:20:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 478 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-12-21 09:53:27
合計ジャッジ時間 2,613 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

memo = {}


def dfs(i, pre_use):
    if i == len(value_list):
        return 0

    if (i, pre_use) in memo:
        return memo[(i, pre_use)]

    ans = 0
    ans = max(ans, dfs(i + 1, False))
    if not pre_use:
        ans = max(ans, dfs(i + 1, True) + value_list[i])

    memo[(i, pre_use)] = ans
    return ans


if __name__ == '__main__':
    n = int(input())
    value_list = list(map(int, input().split()))
    print(dfs(0, False))

0