結果

問題 No.2150 Site Supporter
ユーザー merom686
提出日時 2022-12-07 00:46:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 192,968 KB
最終ジャッジ日時 2025-02-09 05:54:04
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k, x;
    cin >> n >> k >> x;

    array<ll, 2> dp = { 0, 1LL << 60 };
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        auto p = dp;
        dp[0] = min(p[0], p[1]) + a;
        dp[1] = min(p[0] + x, p[1]) + k;
    }
    cout << min(dp[0], dp[1]) << endl;

    return 0;
}
0