結果

問題 No.45 回転寿司
ユーザー koyopro
提出日時 2015-09-20 21:38:03
言語 PyPy2
(7.3.20)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 287 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 345 ms
コンパイル使用メモリ 77,860 KB
最終ジャッジ日時 2025-12-03 17:10:45
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- coding: utf-8 -*-

N, = map(int, raw_input().split())
V = map(int, raw_input().split())

# 動的計画法
maxv = {len(V)+1: 0}
for i in xrange(len(V), -1, -1):
    if i >= len(V):
        maxv[i] = 0
    else:
        maxv[i] = max(V[i] + maxv[i + 2], maxv[i + 1])

print maxv[0]
0