結果

問題 No.409 ダイエット
ユーザー 0w10w1
提出日時 2019-11-26 11:50:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 904 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 79,596 KB
実行使用メモリ 4,708 KB
最終ジャッジ日時 2023-08-06 11:53:51
合計ジャッジ時間 11,708 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;
struct mat {
  int i;
  int X;
  long long w;
};

int main() {
  int N, A, B, W;
  long long ans;
  cin >> N >> A >> B >> W;
  int D[N];
  for (int i = 0; i < N; i++) {
    cin >> D[i];
  }
  queue<mat> v;
  struct mat d1ST = {0, 1, W + B - A};
  struct mat d1SL = {0, 0, W + D[0]};
  ans = (d1SL.w < d1ST.w) ? d1SL.w : d1ST.w;
  int minSleep;
  if (N > 1) {
    v.push(d1ST);
    v.push(d1SL);
    minSleep = W + D[0];
  }
  for (int i = 1; i < N; i++) {
    minSleep = ans + D[i];
    ans += D[i];
    while (v.front().i == i - 1) {
      struct mat tmp = v.front();
      v.pop();
      struct mat st = {i, tmp.X + 1, tmp.w + (tmp.X + 1) * B - A};

      if (st.w < minSleep) {
        if (st.w < ans) ans = st.w;
        v.push(st);
      }
    }
    struct mat mS = {i, 0, minSleep};
    v.push(mS);
  }
  cout << ans << endl;
  return 0;
}
0