結果

問題 No.45 回転寿司
ユーザー _yoshih__yoshih_
提出日時 2018-10-01 13:05:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 920 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 78,524 KB
実行使用メモリ 814,820 KB
最終ジャッジ日時 2024-04-20 14:07:33
合計ジャッジ時間 6,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

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