結果

問題 No.45 回転寿司
ユーザー maburoe
提出日時 2019-06-18 16:09:08
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 21 ms / 5,000 ms
+ 975µs
コード長 291 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-08 18:03:25
合計ジャッジ時間 3,203 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

if n == 1:
    print(sushi_plates.pop())
    exit()

answers = [0] * (n + 1)
answers[1] = sushi_plates[0]
for i in range(2, n + 1):
    answers[i] = max(answers[i - 1], answers[i - 2] + sushi_plates[i - 1])

print(answers[n])
0