結果

問題 No.126 2基のエレベータ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 20:17:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 801 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 41,920 KB
最終ジャッジ日時 2024-04-19 01:44:19
合計ジャッジ時間 7,159 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,268 KB
testcase_01 AC 131 ms
41,568 KB
testcase_02 AC 132 ms
41,540 KB
testcase_03 AC 132 ms
41,212 KB
testcase_04 AC 133 ms
41,512 KB
testcase_05 AC 129 ms
41,216 KB
testcase_06 AC 120 ms
40,164 KB
testcase_07 AC 132 ms
41,572 KB
testcase_08 AC 130 ms
41,220 KB
testcase_09 AC 132 ms
41,296 KB
testcase_10 AC 132 ms
41,604 KB
testcase_11 AC 132 ms
41,104 KB
testcase_12 AC 132 ms
41,396 KB
testcase_13 AC 133 ms
41,592 KB
testcase_14 AC 129 ms
41,676 KB
testcase_15 AC 135 ms
41,632 KB
testcase_16 AC 132 ms
41,632 KB
testcase_17 AC 133 ms
41,920 KB
testcase_18 AC 133 ms
41,752 KB
testcase_19 AC 132 ms
41,392 KB
testcase_20 AC 135 ms
41,652 KB
testcase_21 AC 132 ms
41,716 KB
testcase_22 AC 120 ms
41,264 KB
testcase_23 AC 132 ms
41,404 KB
testcase_24 AC 129 ms
41,424 KB
testcase_25 AC 131 ms
41,568 KB
testcase_26 AC 133 ms
41,560 KB
testcase_27 AC 132 ms
41,604 KB
testcase_28 AC 131 ms
41,268 KB
testcase_29 AC 132 ms
41,872 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){
            if(dista>=s){
                min = distb+s+a-1;
            }else{
                min = distb+dista+a;
            }
        }else if(distb<dista&&a==0){
            min = distb+s+1;
        }
         else{
            min = distb+dista+a;
        }
        System.out.println(min);
    }    
}
0