結果

問題 No.409 ダイエット
ユーザー 0w10w1
提出日時 2019-11-12 04:15:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 198,948 KB
実行使用メモリ 18,124 KB
最終ジャッジ日時 2023-10-14 12:48:05
合計ジャッジ時間 7,213 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,352 KB
testcase_20 AC 2 ms
4,356 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,352 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,352 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,352 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,352 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 2 ms
4,352 KB
testcase_35 AC 2 ms
4,352 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,352 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 WA -
testcase_41 AC 2 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 3 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,352 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,352 KB
testcase_54 WA -
testcase_55 AC 27 ms
10,496 KB
testcase_56 AC 52 ms
17,568 KB
testcase_57 AC 53 ms
18,124 KB
testcase_58 AC 24 ms
9,572 KB
testcase_59 WA -
testcase_60 AC 20 ms
9,096 KB
testcase_61 AC 47 ms
16,400 KB
testcase_62 AC 50 ms
17,256 KB
testcase_63 AC 45 ms
16,124 KB
testcase_64 AC 25 ms
10,112 KB
testcase_65 WA -
testcase_66 AC 53 ms
18,072 KB
testcase_67 AC 40 ms
14,264 KB
testcase_68 WA -
testcase_69 AC 47 ms
15,852 KB
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 AC 7 ms
4,352 KB
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N, A, B, W;
int D[1000000];
int64_t num, sol;
int Wa, Wb, Wc;
int X, X2;

int rec(int Wa, int Wb, int Wc, int X, int X2, int num) {
  if (num != N) {
    return rec(
        min(min(Wb + D[num], Wc + D[num]), Wa + D[num]), Wa - A + B,
        Wb - A + X * B < Wc - A + X2 * B ? Wb - A + X * B : Wc - A + X2 * B, 2,
        Wb - A + X * B < Wc - A + X2 * B ? X + 1 : X2 + 1, num + 1);
  }
  return sol = min(min(Wa, Wb), Wc);
}

int main() {
  cin >> N >> A >> B >> W;
  for (int i = 0; i < N; i++) cin >> D[i];
  rec(W, W, W, 1, 1, 0);
  cout << sol << endl;
}
0