結果

問題 No.23 技の選択
ユーザー sei0osei0o
提出日時 2017-10-19 07:39:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 959 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 93,140 KB
実行使用メモリ 785,272 KB
最終ジャッジ日時 2024-05-01 05:43:52
合計ジャッジ時間 8,972 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 AC 115 ms
378,008 KB
testcase_08 AC 226 ms
486,412 KB
testcase_09 MLE -
testcase_10 AC 167 ms
504,444 KB
testcase_11 AC 3 ms
7,888 KB
testcase_12 AC 118 ms
392,872 KB
testcase_13 MLE -
testcase_14 AC 151 ms
471,208 KB
testcase_15 MLE -
testcase_16 AC 13 ms
53,044 KB
testcase_17 AC 119 ms
399,612 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 39 ms
157,868 KB
testcase_21 AC 26 ms
112,532 KB
testcase_22 MLE -
testcase_23 AC 41 ms
163,744 KB
testcase_24 AC 17 ms
75,868 KB
testcase_25 MLE -
testcase_26 AC 41 ms
161,452 KB
testcase_27 MLE -
testcase_28 MLE -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

double dp[10002][10002]; // dp[i][k] = i回攻撃して、そのうちのk回を必殺技にしたときの残りHP

int main() {
    int H, A, D;
    cin >> H >> A >> D;

    double mn = INF;
    for (int i = 0; i < H; i++) for (int k = 0; k < H; k++) dp[i][k] = INF;
    dp[0][0] = H;
    for (int i = 0; i < H; i++) {
        for (int k = 0; k <= i; k++) {
            if (dp[i][k] <= 0) {
                mn = min(mn, (i-k) + k * 1.5);
                continue;
            }
            // 必殺技をする
            dp[i+1][k+1] = min(dp[i+1][k+1], dp[i][k] - D);
            // 通常攻撃をする
            dp[i+1][k] = min(dp[i+1][k], dp[i][k] - A);
        }
    }

    cout << mn << endl;

    return 0;
}
0