結果

問題 No.23 技の選択
ユーザー alpha_virginisalpha_virginis
提出日時 2016-12-17 01:44:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 163,680 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-20 18:37:24
合計ジャッジ時間 5,561 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);

int h, a, d;
double es[11234];

double e(int x) {
  if( x <= 0 ) return 0.0;
  return es[x];
}

int main() {
  scanf("%d %d %d", &h, &a, &d);
  for(int i = 1; i <= h; ++i) {
    double base = 0.0;
    double min = 10000000;
    for(int j = 0; j < 100; ++j) {
      if( j > 0 ) base += pow(1.0/3.0, j) * (j + e(i-d));
      double t = 2.0 * base + pow(1.0/3.0, j) * ((j + 1) + e(i-a));
      min = std::min(min, t);
      // dumpd(t);
    }
    dumpd(min);
    double t1 = 1.0 + e(i-a);
    double t2 = 2.0 * (pow(1.0/3.0, 1) * (1 + e(i-d))) + (1.0/3.0) * (2 + e(i-a));
    double t3 = 2.0/3.0 * (1 + e(i-d)) + (1.0/3.0)*(2.0/3.0) * (2 + e(i-d)) + (1.0/3.0)*(1.0/3.0)*(3 + e(i-a));
    double t4 = 2.0 * (pow(1.0/3.0, 1) * (1 + e(i-d)) + pow(1.0/3.0, 2) * (2 + e(i-d)) + pow(1.0/3.0, 3) * (3 + e(i-d))) + pow(1.0/3.0, 3) * (4 + e(i-a));
    dumpd(t1);
    dumpd(t2);
    dumpd(t3);
    dumpd(t4);
    es[i] = std::min(std::min(std::min(t1, t2), t3), t4);
  }

  return 0;
}
0