結果
問題 | No.2150 Site Supporter |
ユーザー | tnakao0123 |
提出日時 | 2022-12-09 11:08:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 926 bytes |
コンパイル時間 | 315 ms |
コンパイル使用メモリ | 42,180 KB |
実行使用メモリ | 6,528 KB |
最終ジャッジ日時 | 2024-10-14 18:35:14 |
合計ジャッジ時間 | 1,698 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
/* -*- coding: utf-8 -*- * * 2150.cc: No.2150 Site Supporter - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; const long long LINF = 1LL << 62; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; ll dp0[MAX_N + 1], dp1[MAX_N + 1]; /* subroutines */ inline void setmin(ll &a, ll b) { if (a > b) a = b; } /* main */ int main() { int n, k, x; scanf("%d%d%d", &n, &k, &x); for (int i = 0; i < n; i++) scanf("%d", as + i); fill(dp0, dp0 + n + 1, LINF); fill(dp1, dp1 + n + 1, LINF); dp0[0] = 0; for (int i = 0; i < n; i++) { if (dp0[i] < LINF) { setmin(dp0[i + 1], dp0[i] + as[i]); setmin(dp1[i + 1], dp0[i] + x + k); } if (dp1[i] < LINF) { setmin(dp0[i + 1], dp1[i] + as[i]); setmin(dp1[i + 1], dp1[i] + k); } } printf("%lld\n", min(dp0[n], dp1[n])); return 0; }