結果

問題 No.45 回転寿司
ユーザー saio4016
提出日時 2019-02-18 09:39:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 159,104 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-05 03:38:52
合計ジャッジ時間 2,132 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int dp[1010];

int main()
{
    int n;
    cin >> n;
    vector<int> v(n+10,0);
    for(int i = 0; i < n; i++) cin >> v[i];
    dp[0] = v[0];
    dp[1] = v[1];
    for(int i = 0; i < n; i++){
        dp[i+2] = max(dp[i]+v[i+2],dp[i+2]);
        dp[i+3] = max(dp[i]+v[i+3],dp[i+3]);
    }
    cout << dp[n-1] << endl;
    return 0;
}
0