結果

問題 No.126 2基のエレベータ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-21 17:17:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 72,092 KB
実行使用メモリ 56,236 KB
最終ジャッジ日時 2023-08-18 06:10:36
合計ジャッジ時間 7,276 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 125 ms
55,456 KB
testcase_02 AC 123 ms
55,572 KB
testcase_03 AC 124 ms
55,936 KB
testcase_04 AC 126 ms
53,700 KB
testcase_05 AC 125 ms
55,572 KB
testcase_06 AC 125 ms
55,880 KB
testcase_07 AC 124 ms
56,216 KB
testcase_08 AC 125 ms
53,768 KB
testcase_09 AC 126 ms
55,624 KB
testcase_10 AC 127 ms
55,756 KB
testcase_11 AC 127 ms
55,740 KB
testcase_12 AC 128 ms
55,916 KB
testcase_13 AC 126 ms
55,448 KB
testcase_14 AC 125 ms
55,916 KB
testcase_15 AC 125 ms
55,876 KB
testcase_16 WA -
testcase_17 AC 125 ms
55,856 KB
testcase_18 AC 126 ms
56,000 KB
testcase_19 AC 126 ms
55,664 KB
testcase_20 AC 128 ms
55,928 KB
testcase_21 AC 126 ms
53,848 KB
testcase_22 AC 126 ms
55,652 KB
testcase_23 AC 126 ms
56,040 KB
testcase_24 AC 127 ms
55,704 KB
testcase_25 AC 126 ms
55,784 KB
testcase_26 AC 125 ms
56,052 KB
testcase_27 AC 124 ms
55,868 KB
testcase_28 AC 124 ms
55,420 KB
testcase_29 AC 125 ms
55,428 KB
権限があれば一括ダウンロードができます

ソースコード

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{
                if(A>B||A==0){
                    min=Bmove+S+Math.abs(A-1);
                }else{
                    min=Bmove+S;
                }
            }
        }
        System.out.println(min);
    }
}
0