結果

問題 No.45 回転寿司
ユーザー _yoshih_
提出日時 2018-10-01 13:05:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 920 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 79,228 KB
実行使用メモリ 814,564 KB
最終ジャッジ日時 2024-10-12 09:40:09
合計ジャッジ時間 6,769 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other MLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

static void setup()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Action
{
    int pos;
    int point;
};

static void run()
{
    int n;
    cin >> n;

    vector<int> vs;
    vs.resize(n);
    for (auto i = 0; i < n; ++i) {
        cin >> vs[i];
    }

    queue<Action> q;
    q.push(Action{ 0, 0 });
    q.push(Action{ 1, 0 });

    int result = 0;
    while (!q.empty()) {
        const auto action = q.front();
        q.pop();

        if (action.pos >= n) {
            result = max(result, action.point);
            continue;
        }

        q.push(Action{ action.pos + 1, action.point });
        q.push(Action{ action.pos + 2, action.point + vs[action.pos] });
    }

    cout << result << endl;
}

int main(int argc, char **argv)
{
    setup();
    run();
    return 0;
}
0