結果

問題 No.23 技の選択
ユーザー tentententen
提出日時 2021-03-05 18:17:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 1,303 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 79,836 KB
実行使用メモリ 41,716 KB
最終ジャッジ日時 2024-04-16 06:24:47
合計ジャッジ時間 8,116 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,408 KB
testcase_01 AC 121 ms
40,124 KB
testcase_02 AC 132 ms
41,380 KB
testcase_03 AC 149 ms
41,716 KB
testcase_04 AC 148 ms
41,452 KB
testcase_05 AC 148 ms
41,576 KB
testcase_06 AC 136 ms
41,096 KB
testcase_07 AC 121 ms
40,284 KB
testcase_08 AC 136 ms
41,344 KB
testcase_09 AC 151 ms
41,548 KB
testcase_10 AC 136 ms
41,300 KB
testcase_11 AC 135 ms
41,056 KB
testcase_12 AC 135 ms
41,120 KB
testcase_13 AC 119 ms
40,264 KB
testcase_14 AC 131 ms
41,400 KB
testcase_15 AC 135 ms
41,304 KB
testcase_16 AC 137 ms
41,408 KB
testcase_17 AC 134 ms
41,196 KB
testcase_18 AC 133 ms
41,344 KB
testcase_19 AC 132 ms
41,048 KB
testcase_20 AC 129 ms
41,204 KB
testcase_21 AC 133 ms
41,384 KB
testcase_22 AC 134 ms
41,220 KB
testcase_23 AC 130 ms
41,276 KB
testcase_24 AC 129 ms
41,112 KB
testcase_25 AC 129 ms
41,168 KB
testcase_26 AC 133 ms
40,992 KB
testcase_27 AC 132 ms
40,868 KB
testcase_28 AC 132 ms
41,428 KB
testcase_29 AC 138 ms
41,516 KB
testcase_30 AC 134 ms
41,416 KB
testcase_31 AC 132 ms
41,560 KB
testcase_32 AC 136 ms
41,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int a = sc.nextInt();
        int d = sc.nextInt();
        TreeMap<Double, Integer> status = new TreeMap<>();
        status.put(0.0, h);
        double ans = Double.MAX_VALUE;
        while (status.size() > 0) {
            Map.Entry<Double, Integer> entry = status.pollFirstEntry();
            if (entry.getValue() <= a) {
                ans = Math.min(entry.getKey() + 1, ans);
            } else {
                double nextKey = entry.getKey() + 1;
                int nextValue = entry.getValue() - a;
                if (!status.containsKey(nextKey) || status.get(nextKey) > nextValue) {
                    status.put(nextKey, nextValue);
                }
            }
            if (entry.getValue() <= d) {
                ans = Math.min(entry.getKey() + 1.5, ans);
            } else {
                double nextKey = entry.getKey() + 1.5;
                int nextValue = entry.getValue() - d;
                if (!status.containsKey(nextKey) || status.get(nextKey) > nextValue) {
                    status.put(nextKey, nextValue);
                }
            }
        }
        System.out.println(ans);
    }
}
0