結果

問題 No.23 技の選択
ユーザー hirogahiroga
提出日時 2020-01-14 05:41:02
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 284 ms / 5,000 ms
コード長 1,033 bytes
コンパイル時間 10,826 ms
コンパイル使用メモリ 428,924 KB
実行使用メモリ 53,100 KB
最終ジャッジ日時 2023-08-25 16:22:16
合計ジャッジ時間 21,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 251 ms
53,048 KB
testcase_01 AC 250 ms
53,076 KB
testcase_02 AC 257 ms
52,780 KB
testcase_03 AC 260 ms
52,988 KB
testcase_04 AC 254 ms
52,776 KB
testcase_05 AC 275 ms
53,036 KB
testcase_06 AC 263 ms
52,924 KB
testcase_07 AC 252 ms
52,900 KB
testcase_08 AC 245 ms
52,780 KB
testcase_09 AC 247 ms
52,880 KB
testcase_10 AC 268 ms
52,980 KB
testcase_11 AC 270 ms
52,844 KB
testcase_12 AC 252 ms
52,768 KB
testcase_13 AC 252 ms
52,920 KB
testcase_14 AC 254 ms
53,028 KB
testcase_15 AC 242 ms
52,988 KB
testcase_16 AC 242 ms
52,920 KB
testcase_17 AC 245 ms
52,792 KB
testcase_18 AC 253 ms
52,868 KB
testcase_19 AC 251 ms
52,980 KB
testcase_20 AC 251 ms
52,852 KB
testcase_21 AC 248 ms
52,868 KB
testcase_22 AC 260 ms
52,936 KB
testcase_23 AC 284 ms
52,972 KB
testcase_24 AC 273 ms
52,756 KB
testcase_25 AC 272 ms
52,884 KB
testcase_26 AC 268 ms
52,888 KB
testcase_27 AC 262 ms
52,896 KB
testcase_28 AC 249 ms
52,972 KB
testcase_29 AC 252 ms
53,100 KB
testcase_30 AC 253 ms
52,876 KB
testcase_31 AC 250 ms
52,888 KB
testcase_32 AC 252 ms
52,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:29:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import kotlin.math.min

private const val SPECIAL_ATTACK_HIT_RATE = 2.0 / 3.0
private const val SPECIAL_ATTACK_NUM_EXPECTED = 1.0 / SPECIAL_ATTACK_HIT_RATE

internal fun solve(HP: Int, normal: Int, special: Int): String {
    var counter = Double.MAX_VALUE
    fun updateIfNewRecord(record: Double){
        counter = min(counter, record)
    }

    for (n in 0..Int.MAX_VALUE){
        var currentHP: Double = (HP - normal * n).toDouble()
        if (currentHP <= 0){
            updateIfNewRecord(n.toDouble())
            break
        }
        for (m in 1..Int.MAX_VALUE){
            currentHP -= special
            if (currentHP <= 0){
                updateIfNewRecord(n + m * SPECIAL_ATTACK_NUM_EXPECTED)
                break
            }
        }
    }
    return counter.toString()
}

fun main(args: Array<String>) {
    var OUTPUT = ""

    val br = System.`in`.bufferedReader()
    val (HP, normal, special) = br.readLine().split(" ").map { it.toInt() }

    OUTPUT += solve(HP, normal, special)
    print(OUTPUT)
}
0