結果

問題 No.126 2基のエレベータ
ユーザー バカらっくバカらっく
提出日時 2019-10-02 12:07:08
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 303 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 12,112 ms
コンパイル使用メモリ 431,692 KB
実行使用メモリ 51,764 KB
最終ジャッジ日時 2024-04-19 01:56:13
合計ジャッジ時間 22,639 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
51,676 KB
testcase_01 AC 293 ms
51,644 KB
testcase_02 AC 284 ms
51,708 KB
testcase_03 AC 282 ms
51,372 KB
testcase_04 AC 279 ms
51,712 KB
testcase_05 AC 295 ms
51,496 KB
testcase_06 AC 290 ms
51,680 KB
testcase_07 AC 277 ms
51,384 KB
testcase_08 AC 286 ms
51,456 KB
testcase_09 AC 292 ms
51,592 KB
testcase_10 AC 281 ms
51,532 KB
testcase_11 AC 302 ms
51,532 KB
testcase_12 AC 288 ms
51,620 KB
testcase_13 AC 300 ms
51,460 KB
testcase_14 AC 290 ms
51,764 KB
testcase_15 AC 291 ms
51,656 KB
testcase_16 AC 281 ms
51,328 KB
testcase_17 AC 280 ms
51,532 KB
testcase_18 AC 303 ms
51,596 KB
testcase_19 AC 292 ms
51,580 KB
testcase_20 AC 293 ms
51,432 KB
testcase_21 AC 282 ms
51,664 KB
testcase_22 AC 278 ms
51,652 KB
testcase_23 AC 274 ms
51,668 KB
testcase_24 AC 285 ms
51,344 KB
testcase_25 AC 284 ms
51,576 KB
testcase_26 AC 290 ms
51,528 KB
testcase_27 AC 281 ms
51,564 KB
testcase_28 AC 283 ms
51,524 KB
testcase_29 AC 280 ms
51,400 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