結果

問題 No.45 回転寿司
ユーザー shinshin
提出日時 2022-10-10 16:58:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 419 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-24 11:02:36
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#回転ずし

N = int(input())
V = list(map(int , input().split()))

total = list(0 for i in range(N))

if N == 1:
    total[0] = V[0]
elif N == 2:
    total[1] = max(V)
else:
    total[0] = V[0]
    total[1] = V[1]
    if N == 3:
        total[2] = max(V[0] + V[2] , V[1])
    else:
        for i in range(2 , N):
            total[i] = max(total[i - 2] + V[i] , total[i - 3] + V[i] , total[i - 1])

print(total[N-1])
0