結果

問題 No.126 2基のエレベータ
ユーザー バカらっくバカらっく
提出日時 2019-10-02 12:07:08
言語 Kotlin
(1.9.10)
結果
AC  
実行時間 305 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 14,329 ms
コンパイル使用メモリ 423,012 KB
実行使用メモリ 53,368 KB
最終ジャッジ日時 2023-08-01 02:11:24
合計ジャッジ時間 24,005 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
52,948 KB
testcase_01 AC 298 ms
52,864 KB
testcase_02 AC 297 ms
52,964 KB
testcase_03 AC 294 ms
53,368 KB
testcase_04 AC 295 ms
52,980 KB
testcase_05 AC 296 ms
52,872 KB
testcase_06 AC 294 ms
53,088 KB
testcase_07 AC 294 ms
52,860 KB
testcase_08 AC 299 ms
52,920 KB
testcase_09 AC 292 ms
52,956 KB
testcase_10 AC 305 ms
52,944 KB
testcase_11 AC 295 ms
52,976 KB
testcase_12 AC 294 ms
53,048 KB
testcase_13 AC 292 ms
52,916 KB
testcase_14 AC 291 ms
53,000 KB
testcase_15 AC 290 ms
52,780 KB
testcase_16 AC 292 ms
52,984 KB
testcase_17 AC 291 ms
52,836 KB
testcase_18 AC 291 ms
52,900 KB
testcase_19 AC 291 ms
52,948 KB
testcase_20 AC 293 ms
52,904 KB
testcase_21 AC 293 ms
52,952 KB
testcase_22 AC 293 ms
53,140 KB
testcase_23 AC 295 ms
53,072 KB
testcase_24 AC 305 ms
52,968 KB
testcase_25 AC 303 ms
52,856 KB
testcase_26 AC 298 ms
52,988 KB
testcase_27 AC 292 ms
52,916 KB
testcase_28 AC 298 ms
52,996 KB
testcase_29 AC 300 ms
53,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

diff #

fun main(args:Array<String>) {
    val (a,b,s) = readLine()!!.split(" ").map { it.toInt() }
    println(getAns(a,b,s))
}

fun getAns(a:Int, b:Int, s:Int):Int {
    if(s == 1) {
        if(a == 0) {
            return 2
        } else {
            return a
        }
    }
    if(Math.abs(a-s) > Math.abs(b-s)) {
        return Math.min(getAns(a, 1, 1) + Math.abs(b-s) + Math.abs(s - 1), Math.abs(b-s) + Math.abs(s-Math.max(a, 1)) + getAns(a, s, Math.max(a, 1)))
    }
    return Math.abs(a-s) + s
}
0