結果
| 問題 | 
                            No.126 2基のエレベータ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             バカらっく
                         | 
                    
| 提出日時 | 2019-10-02 12:02:48 | 
| 言語 | Kotlin  (2.1.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 460 bytes | 
| コンパイル時間 | 9,924 ms | 
| コンパイル使用メモリ | 437,276 KB | 
| 実行使用メモリ | 56,992 KB | 
| 最終ジャッジ日時 | 2024-10-03 05:58:27 | 
| 合計ジャッジ時間 | 19,120 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 WA * 2 | 
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^
            
            ソースコード
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
}
            
            
            
        
            
バカらっく