結果

問題 No.45 回転寿司
ユーザー nebukuro09
提出日時 2016-09-03 09:28:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 276 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2024-12-27 15:21:42
合計ジャッジ時間 1,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000)

N = input()
V = map(int, raw_input().split())
mem = [0 for i in xrange(N)]

def rec(n):
    if n >= N:
        return 0
    if mem[n] > 0:
        return mem[n]
    mem[n] = max(rec(n+1), rec(n+2)+V[n])
    return mem[n]

print rec(0)
0