結果

問題 No.45 回転寿司
ユーザー tetsuzuki1115
提出日時 2017-10-22 12:34:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 690 bytes
コンパイル時間 2,509 ms
コンパイル使用メモリ 80,068 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 17:34:00
合計ジャッジ時間 1,795 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    vector<int> V(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> V[i];
    }
    
    int dp[1000][2];
    
    dp[0][0] = 0; dp[0][1] = V[0];
    for ( int i = 1; i < N; i++ ) {
        dp[i][0] = max( dp[i-1][1], dp[i-1][0] );
        dp[i][1] = dp[i-1][0] + V[i];
    }
    
    cout << max( dp[N-1][1], dp[N-1][0] ) << endl;
    
    return 0;
}
0