結果

問題 No.126 2基のエレベータ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 20:06:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 71,508 KB
実行使用メモリ 58,312 KB
最終ジャッジ日時 2023-09-17 06:18:26
合計ジャッジ時間 7,029 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 121 ms
55,708 KB
testcase_03 AC 122 ms
56,160 KB
testcase_04 AC 122 ms
55,760 KB
testcase_05 AC 124 ms
54,224 KB
testcase_06 AC 122 ms
56,008 KB
testcase_07 WA -
testcase_08 AC 125 ms
56,076 KB
testcase_09 AC 123 ms
56,108 KB
testcase_10 AC 123 ms
55,792 KB
testcase_11 AC 123 ms
55,960 KB
testcase_12 AC 122 ms
55,792 KB
testcase_13 AC 124 ms
55,936 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 125 ms
55,804 KB
testcase_19 AC 125 ms
55,860 KB
testcase_20 WA -
testcase_21 AC 125 ms
55,968 KB
testcase_22 AC 124 ms
56,344 KB
testcase_23 AC 123 ms
55,556 KB
testcase_24 AC 123 ms
56,016 KB
testcase_25 AC 123 ms
55,780 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 123 ms
55,568 KB
testcase_29 AC 123 ms
56,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int a = koko.nextInt();
        int b = koko.nextInt();
        int s = koko.nextInt();
        int dista = Math.abs(a-s);
        int distb = Math.abs(b-s);
        int min;
        if(dista<=distb){
            min = dista+s;
        }else if(distb<dista&&s==1){
            min = dista+1;
        }else if(distb<dista&&a>b){
            min = distb+s+a+1;
        }else{
            min = distb+dista+a;
        }
        System.out.println(min);
    }    
}
0