結果

問題 No.2150 Site Supporter
ユーザー daiotadaiota
提出日時 2022-12-07 08:30:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 3,748 ms
コンパイル使用メモリ 164,324 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2023-08-03 19:32:17
合計ジャッジ時間 3,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,640 KB
testcase_01 AC 2 ms
5,420 KB
testcase_02 AC 2 ms
5,448 KB
testcase_03 AC 2 ms
5,540 KB
testcase_04 AC 2 ms
5,408 KB
testcase_05 AC 2 ms
5,400 KB
testcase_06 AC 2 ms
5,572 KB
testcase_07 AC 2 ms
5,400 KB
testcase_08 AC 6 ms
5,792 KB
testcase_09 AC 23 ms
7,560 KB
testcase_10 AC 13 ms
6,540 KB
testcase_11 AC 22 ms
7,400 KB
testcase_12 AC 10 ms
6,360 KB
testcase_13 AC 6 ms
6,020 KB
testcase_14 AC 2 ms
5,404 KB
testcase_15 AC 2 ms
5,480 KB
testcase_16 AC 2 ms
5,400 KB
testcase_17 AC 26 ms
8,064 KB
testcase_18 AC 11 ms
6,448 KB
testcase_19 AC 5 ms
5,788 KB
testcase_20 AC 18 ms
6,872 KB
testcase_21 AC 4 ms
5,588 KB
testcase_22 AC 23 ms
7,584 KB
testcase_23 AC 2 ms
5,612 KB
testcase_24 AC 2 ms
5,420 KB
testcase_25 AC 2 ms
5,408 KB
testcase_26 AC 2 ms
5,400 KB
testcase_27 AC 15 ms
6,664 KB
testcase_28 AC 15 ms
6,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
typedef long long ll;
typedef pair<int,int> P;

ll a[200010],dp[2][200010];

int main(void){
	int i;

	cin.tie(0);  ios_base::sync_with_stdio(false);

	ll N,K,X;
	cin >> N >> K >> X;
	for(i=1;i<=N;i++) cin >> a[i];

	for(i=1;i<=N;i++){
		dp[0][i]=1e18; dp[1][i]=1e18;
		dp[0][i]=min(dp[0][i-1]+a[i],dp[1][i-1]+a[i]);
		if(i==1) dp[1][i]=K+X;
		else dp[1][i]=min(dp[0][i-1]+K+X,dp[1][i-1]+K);
	}


	cout << min(dp[0][N],dp[1][N]) << endl;


	return 0;
}
0