結果

問題 No.2150 Site Supporter
ユーザー LanatusLanatus
提出日時 2022-12-07 16:12:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 2,343 ms
コンパイル使用メモリ 200,012 KB
実行使用メモリ 14,760 KB
最終ジャッジ日時 2024-04-21 23:33:22
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 15 ms
5,376 KB
testcase_09 AC 86 ms
13,768 KB
testcase_10 AC 44 ms
8,448 KB
testcase_11 AC 80 ms
13,004 KB
testcase_12 AC 33 ms
7,040 KB
testcase_13 AC 19 ms
5,632 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 94 ms
14,760 KB
testcase_18 AC 38 ms
7,680 KB
testcase_19 AC 13 ms
5,376 KB
testcase_20 AC 64 ms
10,880 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 87 ms
13,696 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 55 ms
9,472 KB
testcase_28 AC 54 ms
8,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define all(v) begin(v), end(v)

using namespace std;

using ll = long long;

const ll INF = 1e18;

int main(void) {
  ll n, k, x;
  cin >> n >> k >> x;

  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(2, INF));
  dp[0][0] = 0;

  for (int i = 1; i <= n; ++i) {
    dp[i][0] = min(dp[i-1][0] + a[i-1], dp[i-1][1] + a[i-1]);
    dp[i][1] = min(dp[i-1][0] + k + x, dp[i-1][1] + k);
  }

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