結果
問題 | No.2150 Site Supporter |
ユーザー |
![]() |
提出日時 | 2022-12-07 00:14:27 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 707 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 28,544 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 11:22:42 |
合計ジャッジ時間 | 1,731 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <stdio.h> int main () { int n = 0; long long k = 0LL; long long x = 0LL; long long a = 0LL; int res = 0; long long dp[2] = {}; res = scanf("%d", &n); res = scanf("%lld", &k); res = scanf("%lld", &x); res = scanf("%lld", &a); dp[0] = a; dp[1] = k+x; for (int i = 1; i < n; i++) { long long nxt[2] = {}; res = scanf("%lld", &a); nxt[0] = dp[0]+a; nxt[1] = dp[1]+k; if (dp[1]+a < nxt[0]) { nxt[0] = dp[1]+a; } if (dp[0]+k+x < nxt[1]) { nxt[1] = dp[0]+k+x; } dp[0] = nxt[0]; dp[1] = nxt[1]; } if (dp[0] < dp[1]) { printf("%lld\n", dp[0]); } else { printf("%lld\n", dp[1]); } return 0; }