結果

問題 No.126 2基のエレベータ
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 20:13:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 2,923 ms
コンパイル使用メモリ 71,004 KB
実行使用メモリ 39,920 KB
最終ジャッジ日時 2023-09-17 06:18:53
合計ジャッジ時間 6,862 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 117 ms
39,216 KB
testcase_02 AC 118 ms
39,604 KB
testcase_03 AC 118 ms
39,032 KB
testcase_04 AC 119 ms
39,288 KB
testcase_05 AC 118 ms
39,168 KB
testcase_06 AC 119 ms
39,296 KB
testcase_07 AC 120 ms
39,216 KB
testcase_08 AC 118 ms
39,344 KB
testcase_09 AC 119 ms
39,384 KB
testcase_10 AC 119 ms
39,252 KB
testcase_11 AC 121 ms
39,400 KB
testcase_12 AC 119 ms
39,096 KB
testcase_13 AC 122 ms
39,568 KB
testcase_14 AC 117 ms
39,452 KB
testcase_15 AC 120 ms
39,316 KB
testcase_16 WA -
testcase_17 AC 118 ms
39,648 KB
testcase_18 AC 123 ms
39,620 KB
testcase_19 AC 121 ms
39,592 KB
testcase_20 AC 121 ms
39,316 KB
testcase_21 AC 119 ms
39,292 KB
testcase_22 AC 124 ms
39,428 KB
testcase_23 AC 119 ms
39,128 KB
testcase_24 AC 119 ms
39,036 KB
testcase_25 AC 119 ms
39,320 KB
testcase_26 AC 118 ms
39,160 KB
testcase_27 AC 120 ms
39,196 KB
testcase_28 AC 115 ms
38,996 KB
testcase_29 AC 116 ms
39,484 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 if(distb<dista&&a==0){
            min = distb+s+1;
        }
         else{
            min = distb+dista+a;
        }
        System.out.println(min);
    }    
}
0