結果

問題 No.126 2基のエレベータ
ユーザー kohaku_kohaku
提出日時 2016-11-21 17:05:27
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 74,108 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-11-27 09:27:48
合計ジャッジ時間 6,435 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int S = sc.nextInt();
        int min=0;
        int Amove=Math.abs(A-S);
        int Bmove=Math.abs(B-S);
        if(S==1){
            min+=Amove+1;
        }else{
            if(Amove<=Bmove){
                min+=Amove+S;
            }else{
                min+=Bmove+S+Math.abs(A-1);
            }
        }
        System.out.println(min);
    }
}
0