結果

問題 No.126 2基のエレベータ
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-12 23:19:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 71,440 KB
実行使用メモリ 57,892 KB
最終ジャッジ日時 2023-09-15 14:23:56
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
56,080 KB
testcase_01 AC 114 ms
56,176 KB
testcase_02 WA -
testcase_03 AC 116 ms
56,056 KB
testcase_04 AC 115 ms
56,404 KB
testcase_05 AC 112 ms
55,820 KB
testcase_06 AC 121 ms
56,728 KB
testcase_07 AC 112 ms
56,244 KB
testcase_08 AC 119 ms
55,824 KB
testcase_09 AC 117 ms
56,116 KB
testcase_10 AC 112 ms
55,800 KB
testcase_11 AC 116 ms
55,632 KB
testcase_12 AC 115 ms
56,040 KB
testcase_13 AC 113 ms
56,116 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 114 ms
55,804 KB
testcase_17 WA -
testcase_18 AC 117 ms
56,096 KB
testcase_19 AC 117 ms
56,140 KB
testcase_20 WA -
testcase_21 AC 118 ms
56,264 KB
testcase_22 AC 118 ms
55,560 KB
testcase_23 AC 120 ms
56,464 KB
testcase_24 AC 114 ms
56,184 KB
testcase_25 AC 116 ms
55,732 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 116 ms
55,900 KB
testcase_29 AC 116 ms
55,688 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 = 0;
    if(Math.abs(a - s) <= Math.abs(b - s)) {
      ans = Math.abs(a - s) + s;
    } else {
      ans = Math.abs(b - s) + Math.abs(a - s) + a;
      if(a == 0) ans++;
    }
    System.out.println(ans);
  }
}
0