結果

問題 No.126 2基のエレベータ
ユーザー htensaihtensai
提出日時 2020-02-06 09:05:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 73,996 KB
実行使用メモリ 57,708 KB
最終ジャッジ日時 2023-10-25 07:40:41
合計ジャッジ時間 7,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,448 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 138 ms
57,692 KB
testcase_04 AC 136 ms
57,476 KB
testcase_05 AC 134 ms
57,400 KB
testcase_06 AC 118 ms
56,184 KB
testcase_07 WA -
testcase_08 AC 130 ms
57,580 KB
testcase_09 AC 132 ms
57,588 KB
testcase_10 AC 133 ms
57,184 KB
testcase_11 AC 132 ms
57,544 KB
testcase_12 AC 129 ms
57,508 KB
testcase_13 AC 132 ms
57,496 KB
testcase_14 AC 140 ms
57,480 KB
testcase_15 AC 135 ms
55,804 KB
testcase_16 AC 131 ms
57,576 KB
testcase_17 AC 135 ms
57,412 KB
testcase_18 AC 135 ms
57,432 KB
testcase_19 AC 135 ms
57,384 KB
testcase_20 AC 136 ms
57,300 KB
testcase_21 AC 136 ms
57,532 KB
testcase_22 AC 132 ms
57,600 KB
testcase_23 AC 136 ms
57,516 KB
testcase_24 AC 136 ms
57,512 KB
testcase_25 AC 137 ms
57,484 KB
testcase_26 AC 133 ms
57,512 KB
testcase_27 AC 135 ms
57,456 KB
testcase_28 AC 137 ms
57,480 KB
testcase_29 AC 137 ms
57,708 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 ans;
        if (a == 0 || Math.abs(s - a) <= Math.abs(s - b)) {
            ans = Math.abs(s - a) + s;
        } else {
            ans = Math.min(Math.abs(s - b) + s - 1 + Math.abs(a - 1) + 1, Math.abs(s - b) + Math.abs(s - a) + a);
        }
        System.out.println(ans);
    }
}
0