結果

問題 No.2150 Site Supporter
ユーザー 👑 chro_96chro_96
提出日時 2022-12-07 00:14:27
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 12:50:57
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 12 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 9 ms
5,376 KB
testcase_13 AC 6 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 24 ms
5,376 KB
testcase_18 AC 11 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 16 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 22 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 15 ms
5,376 KB
testcase_28 AC 14 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0