結果

問題 No.126 2基のエレベータ
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-21 17:05:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 553 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 74,044 KB
実行使用メモリ 54,192 KB
最終ジャッジ日時 2024-05-05 12:15:29
合計ジャッジ時間 6,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 112 ms
41,344 KB
testcase_02 AC 112 ms
41,588 KB
testcase_03 AC 106 ms
40,352 KB
testcase_04 AC 107 ms
41,500 KB
testcase_05 AC 120 ms
41,464 KB
testcase_06 AC 113 ms
40,120 KB
testcase_07 AC 104 ms
40,424 KB
testcase_08 AC 112 ms
41,584 KB
testcase_09 AC 114 ms
41,488 KB
testcase_10 AC 102 ms
39,948 KB
testcase_11 AC 111 ms
41,164 KB
testcase_12 AC 113 ms
41,504 KB
testcase_13 AC 118 ms
41,228 KB
testcase_14 AC 116 ms
41,492 KB
testcase_15 AC 117 ms
41,240 KB
testcase_16 WA -
testcase_17 AC 115 ms
41,488 KB
testcase_18 AC 128 ms
41,592 KB
testcase_19 AC 117 ms
41,420 KB
testcase_20 AC 112 ms
41,408 KB
testcase_21 AC 113 ms
41,280 KB
testcase_22 AC 123 ms
41,636 KB
testcase_23 AC 119 ms
41,496 KB
testcase_24 AC 110 ms
41,480 KB
testcase_25 AC 103 ms
40,328 KB
testcase_26 AC 119 ms
41,260 KB
testcase_27 AC 116 ms
41,192 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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