結果

問題 No.409 ダイエット
ユーザー 0w10w1
提出日時 2019-11-12 18:45:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 3,295 ms
コンパイル使用メモリ 199,664 KB
実行使用メモリ 6,836 KB
最終ジャッジ日時 2023-10-19 09:38:43
合計ジャッジ時間 11,424 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,812 KB
testcase_01 AC 2 ms
5,812 KB
testcase_02 AC 2 ms
5,812 KB
testcase_03 AC 3 ms
5,812 KB
testcase_04 AC 3 ms
5,812 KB
testcase_05 AC 2 ms
5,812 KB
testcase_06 AC 2 ms
5,812 KB
testcase_07 AC 3 ms
5,812 KB
testcase_08 AC 3 ms
5,812 KB
testcase_09 AC 3 ms
5,812 KB
testcase_10 AC 2 ms
5,812 KB
testcase_11 AC 2 ms
5,812 KB
testcase_12 AC 2 ms
5,812 KB
testcase_13 AC 2 ms
5,812 KB
testcase_14 AC 2 ms
5,812 KB
testcase_15 AC 2 ms
5,812 KB
testcase_16 AC 3 ms
5,812 KB
testcase_17 AC 3 ms
5,812 KB
testcase_18 AC 2 ms
5,812 KB
testcase_19 AC 3 ms
5,812 KB
testcase_20 AC 2 ms
5,812 KB
testcase_21 AC 2 ms
5,812 KB
testcase_22 AC 3 ms
5,812 KB
testcase_23 AC 2 ms
5,812 KB
testcase_24 AC 2 ms
5,812 KB
testcase_25 AC 3 ms
5,812 KB
testcase_26 AC 2 ms
5,812 KB
testcase_27 AC 3 ms
5,812 KB
testcase_28 AC 2 ms
5,812 KB
testcase_29 AC 2 ms
5,812 KB
testcase_30 AC 3 ms
5,812 KB
testcase_31 AC 2 ms
5,812 KB
testcase_32 AC 2 ms
5,812 KB
testcase_33 AC 2 ms
5,812 KB
testcase_34 AC 3 ms
5,812 KB
testcase_35 AC 3 ms
5,828 KB
testcase_36 AC 3 ms
5,832 KB
testcase_37 AC 3 ms
5,832 KB
testcase_38 AC 2 ms
5,832 KB
testcase_39 AC 2 ms
5,832 KB
testcase_40 AC 3 ms
5,832 KB
testcase_41 AC 3 ms
5,832 KB
testcase_42 AC 2 ms
5,832 KB
testcase_43 AC 3 ms
5,832 KB
testcase_44 AC 3 ms
5,828 KB
testcase_45 AC 2 ms
5,832 KB
testcase_46 AC 3 ms
5,832 KB
testcase_47 AC 2 ms
5,832 KB
testcase_48 AC 3 ms
5,832 KB
testcase_49 AC 3 ms
5,832 KB
testcase_50 AC 3 ms
5,832 KB
testcase_51 AC 3 ms
5,832 KB
testcase_52 AC 3 ms
5,832 KB
testcase_53 AC 3 ms
5,832 KB
testcase_54 AC 3 ms
5,828 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 RE -
testcase_71 WA -
testcase_72 RE -
testcase_73 RE -
testcase_74 WA -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 RE -
testcase_83 RE -
testcase_84 RE -
testcase_85 AC 5 ms
5,956 KB
testcase_86 WA -
testcase_87 RE -
testcase_88 AC 14 ms
6,836 KB
testcase_89 WA -
testcase_90 AC 14 ms
6,796 KB
testcase_91 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100001;
long long N, A, B, W, D[MAX_N], E[MAX_N], zero[MAX_N], one[MAX_N];

int main() {
  int i, j, k, oneLen;
  long long t, oneMin;

  scanf("%lld %lld %lld %lld", &N, &A, &B, &W);

  D[0] = E[0] = 0;
  for (i = 1; i <= N; i++) {
    scanf("%lld", &D[i]);
    E[i] = E[i - 1] - A + i * B;
  }

  zero[0] = one[0] = W;
  zero[1] = zero[0] + D[1];
  one[1] = one[0] + E[1];
  oneLen = 1;
  for (i = 2; i <= N; i++) {
    zero[i] = std::min(zero[i - 1], one[i - 1]) + D[i];

    oneMin = zero[i - 1] + E[1];
    k = 1;
    for (j = 2; j <= oneLen + 1; j++) {
      t = zero[i - j] + E[j];
      if (t <= oneMin) {
        oneMin = t;
        k = j;
      }
    }
    one[i] = oneMin;
    oneLen = k;
  }

  printf("%lld\n", std::min(zero[N], one[N]));
  return 0;
}
0