結果

問題 No.45 回転寿司
ユーザー CsTarepanda
提出日時 2017-05-04 19:09:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 294 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 280,492 KB
最終ジャッジ日時 2024-09-14 07:13:09
合計ジャッジ時間 15,639 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 2 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

dp = [{} for x in range(n)]

def solve(i, w):
    if -1 < i - 2 < n: w += a[i - 2]
    if i >= n: return w

    if dp[i].get(w):
        return dp[i][w]
    dp[i][w] = w

    return max(solve(i + 2, w), solve(i + 3, w))

print(solve(0, 0))
0