結果

問題 No.45 回転寿司
ユーザー lioo
提出日時 2021-03-29 15:13:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 333 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 62,848 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 09:50:25
合計ジャッジ時間 1,558 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;


int main(){
    int memo[1001];
    int N;
    cin>>N;
    memo[0]=0;

    for(int i=1; i<=N;i++){
        int v;
        cin>>v;
        if(i==1){
            memo[i] = v;
        }else {
            memo[i] = max(memo[i-1], memo[i-2] + v);
        }
    }
    
    cout<<memo[N]<<endl;
}
0