結果

問題 No.45 回転寿司
ユーザー morinaga
提出日時 2020-02-20 02:17:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 429 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 66,504 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 18:33:29
合計ジャッジ時間 1,748 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int tastes[1002];
int dp[1002][2];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> tastes[i];

    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < n; i++)
    {
        dp[i + 1][0] += max(dp[i][0], dp[i][1]);
        dp[i + 1][1] += dp[i][0] + tastes[i];
    }

    cout << max(dp[n][0], dp[n][1]) << endl;
}
0