結果
| 問題 | No.23 技の選択 |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-03-05 18:17:57 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 5,000 ms |
| コード長 | 1,303 bytes |
| 記録 | |
| コンパイル時間 | 1,762 ms |
| コンパイル使用メモリ | 84,604 KB |
| 実行使用メモリ | 43,344 KB |
| 最終ジャッジ日時 | 2026-04-23 04:19:49 |
| 合計ジャッジ時間 | 5,546 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}
tenten