結果

問題 No.23 技の選択
ユーザー yuppe19 😺yuppe19 😺
提出日時 2017-06-18 14:42:16
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 505 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 52,640 KB
最終ジャッジ日時 2024-04-27 02:26:49
合計ジャッジ時間 711 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:3: error: ‘vector’ was not declared in this scope
   10 |   vector<double> dp(h+1, inf); // dp[h+1]
      |   ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
main.cpp:10:10: error: expected primary-expression before ‘double’
   10 |   vector<double> dp(h+1, inf); // dp[h+1]
      |          ^~~~~~
main.cpp:11:3: error: ‘dp’ was not declared in this scope; did you mean ‘d’?
   11 |   dp[0] = 0;
      |   ^~
      |   d
main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   int h, a, d; scanf("%d%d%d", &h, &a, &d);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

constexpr int inf = 987654321;

int main(void) {
  int h, a, d; scanf("%d%d%d", &h, &a, &d);
  // dp[ダメージ量] := 期待する攻撃回数の最小値
  vector<double> dp(h+1, inf); // dp[h+1]
  dp[0] = 0;
  for(int i=0; i<=h; ++i) {
    dp[min(h, i+a)] = min(dp[min(h, i+a)], dp[i] + 1);   // 通常
    dp[min(h, i+d)] = min(dp[min(h, i+d)], dp[i] + 1.5); // 必殺
  }
  double res = dp[h];
  printf("%.15lf\n", res);
  return 0;
}
0