結果

問題 No.45 回転寿司
ユーザー urunea
提出日時 2025-04-22 01:20:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 307 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 54,240 KB
最終ジャッジ日時 2025-04-22 01:20:24
合計ジャッジ時間 3,318 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
V=list(map(int, input().split()))
if N == 1:
    print(V[0])
    exit()
elif N == 2:
    print(max(V[0],V[1]))
    exit()
elif N == 3:
    print(max(V[0]+V[2], V[1]))
    exit()

dp=[V[0],V[1],V[0]+V[2]]
for i in range(3,N):
    dp.append(max(dp[-1], dp[-2]+V[i], dp[-3]+V[i]))

print(dp[-1])
0