結果
| 問題 | No.23 技の選択 | 
| コンテスト | |
| ユーザー |  tenten | 
| 提出日時 | 2021-03-05 18:17:57 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 139 ms / 5,000 ms | 
| コード長 | 1,303 bytes | 
| コンパイル時間 | 2,206 ms | 
| コンパイル使用メモリ | 78,984 KB | 
| 実行使用メモリ | 41,460 KB | 
| 最終ジャッジ日時 | 2024-10-06 19:43:08 | 
| 合計ジャッジ時間 | 7,039 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 | 
ソースコード
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);
    }
}
            
            
            
        