結果

問題 No.126 2基のエレベータ
ユーザー バカらっくバカらっく
提出日時 2019-10-02 11:54:54
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 11,862 ms
コンパイル使用メモリ 426,720 KB
実行使用メモリ 57,036 KB
最終ジャッジ日時 2024-04-14 08:54:06
合計ジャッジ時間 21,842 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 313 ms
56,892 KB
testcase_02 AC 311 ms
56,888 KB
testcase_03 AC 312 ms
56,960 KB
testcase_04 AC 311 ms
56,984 KB
testcase_05 AC 313 ms
56,984 KB
testcase_06 AC 311 ms
56,864 KB
testcase_07 AC 312 ms
56,660 KB
testcase_08 AC 312 ms
56,956 KB
testcase_09 AC 326 ms
56,848 KB
testcase_10 AC 310 ms
56,868 KB
testcase_11 AC 313 ms
56,844 KB
testcase_12 AC 307 ms
56,868 KB
testcase_13 AC 308 ms
56,884 KB
testcase_14 AC 315 ms
56,944 KB
testcase_15 AC 310 ms
56,968 KB
testcase_16 WA -
testcase_17 AC 312 ms
56,868 KB
testcase_18 AC 310 ms
56,836 KB
testcase_19 AC 312 ms
56,860 KB
testcase_20 AC 311 ms
56,932 KB
testcase_21 AC 318 ms
56,968 KB
testcase_22 AC 316 ms
56,900 KB
testcase_23 AC 311 ms
56,912 KB
testcase_24 AC 309 ms
56,928 KB
testcase_25 AC 308 ms
56,948 KB
testcase_26 AC 309 ms
56,940 KB
testcase_27 AC 309 ms
56,872 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 getAns(a, s, 1) + Math.abs(b-s) + (s - 1)
    }
    return Math.abs(a-s) + s
}
0