結果

問題 No.2150 Site Supporter
ユーザー ぷらぷら
提出日時 2022-12-12 00:25:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 195,976 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-04-23 18:41:36
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 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 12 ms
5,376 KB
testcase_09 AC 69 ms
6,784 KB
testcase_10 AC 35 ms
5,376 KB
testcase_11 AC 63 ms
6,528 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 15 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 74 ms
6,784 KB
testcase_18 AC 30 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 48 ms
5,760 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 66 ms
6,784 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 44 ms
5,376 KB
testcase_28 AC 42 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long inf = 1001001001001001001;

void chmin(long long &x,long long y) {
    if(x > y) x = y;
}

long long dp[200200][2];

int main() {
    int N,K,X;
    cin >> N >> K >> X;
    vector<int>A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j < 2; j++) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 2; j++) {
            if(j) {
                chmin(dp[i+1][j],dp[i][j]+K);
                chmin(dp[i+1][0],dp[i][j]+A[i]);
            }
            else {
                chmin(dp[i+1][j],dp[i][j]+A[i]);
                chmin(dp[i+1][1],dp[i][j]+K+X);
            }
        }
    }
    cout << min(dp[N][0],dp[N][1]) << endl;
}
0