結果

問題 No.2150 Site Supporter
ユーザー suisensuisen
提出日時 2022-12-24 03:59:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 73,568 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 12:22:13
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 57 ms
4,376 KB
testcase_10 AC 30 ms
4,380 KB
testcase_11 AC 56 ms
4,380 KB
testcase_12 AC 23 ms
4,380 KB
testcase_13 AC 13 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 66 ms
4,376 KB
testcase_18 AC 26 ms
4,380 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 42 ms
4,380 KB
testcase_21 AC 6 ms
4,380 KB
testcase_22 AC 57 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 39 ms
4,376 KB
testcase_28 AC 37 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <array>
#include <iostream>
#include <limits>
#include <vector>

constexpr uint64_t inf = std::numeric_limits<uint64_t>::max() / 2;

int main() {
    size_t n;
    uint64_t k, x;
    std::cin >> n >> k >> x;

    std::array<uint64_t, 2> pd{ 0, inf };
    for (uint64_t i = 0; i < n; ++i) {
        uint64_t c;
        std::cin >> c;

        std::array<uint64_t, 2> dp{ inf, inf };

        for (bool f : { 0, 1 }) for (bool g : { 0, 1 }) {
            dp[g] = std::min(dp[g], pd[f] + (not g) * c + g * k + (not f and g) * x);
        }
        dp.swap(pd);
    }

    std::cout << std::min(pd[0], pd[1]) << std::endl;
}
0