結果

問題 No.126 2基のエレベータ
ユーザー バカらっくバカらっく
提出日時 2019-10-02 12:02:48
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 12,016 ms
コンパイル使用メモリ 431,700 KB
実行使用メモリ 57,128 KB
最終ジャッジ日時 2024-04-14 08:54:44
合計ジャッジ時間 23,059 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 305 ms
57,004 KB
testcase_01 WA -
testcase_02 AC 312 ms
56,844 KB
testcase_03 AC 313 ms
56,960 KB
testcase_04 AC 311 ms
56,940 KB
testcase_05 AC 309 ms
56,972 KB
testcase_06 AC 309 ms
56,860 KB
testcase_07 WA -
testcase_08 AC 315 ms
56,828 KB
testcase_09 AC 309 ms
57,028 KB
testcase_10 AC 307 ms
56,852 KB
testcase_11 AC 313 ms
56,808 KB
testcase_12 AC 304 ms
56,848 KB
testcase_13 AC 310 ms
56,952 KB
testcase_14 AC 308 ms
56,868 KB
testcase_15 AC 309 ms
56,904 KB
testcase_16 AC 306 ms
57,008 KB
testcase_17 AC 308 ms
57,008 KB
testcase_18 AC 310 ms
56,904 KB
testcase_19 AC 311 ms
56,928 KB
testcase_20 AC 312 ms
56,848 KB
testcase_21 AC 314 ms
56,860 KB
testcase_22 AC 312 ms
56,948 KB
testcase_23 AC 314 ms
56,864 KB
testcase_24 AC 311 ms
56,972 KB
testcase_25 AC 306 ms
56,956 KB
testcase_26 AC 311 ms
56,988 KB
testcase_27 AC 307 ms
56,940 KB
testcase_28 AC 304 ms
56,872 KB
testcase_29 AC 311 ms
57,008 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-a) + a)
    }
    return Math.abs(a-s) + s
}
0