結果
問題 | No.2150 Site Supporter |
ユーザー |
|
提出日時 | 2022-12-11 02:01:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,697 bytes |
コンパイル時間 | 2,002 ms |
コンパイル使用メモリ | 191,860 KB |
最終ジャッジ日時 | 2025-02-09 09:31:16 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>// clang-format offusing namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }#define debug1(a) { cerr<<#a<<":"<<a<<endl; }#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }// clang-format onll N, K, X;ll A[200005];ll dp(ll i, ll pre) {static bool done[200005][2];static ll memo[200005][2];if (done[i][pre]) return memo[i][pre];done[i][pre] = true;if (i == N) {return memo[i][pre] = 0;}ll ans = INF;if (pre) {ans = min(ans, dp(i + 1, 1) + K);ans = min(ans, dp(i + 1, 0) + A[i]);} else {ans = min(ans, dp(i + 1, 1) + X + K);ans = min(ans, dp(i + 1, 0) + A[i]);}return memo[i][pre] = ans;}int main() {ioinit();cin >> N >> K >> X;for (ll i = 0; i < N; i++) cin >> A[i];print(dp(0, 0));return 0;}