結果

問題 No.126 2基のエレベータ
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-12 23:22:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 71,052 KB
実行使用メモリ 57,508 KB
最終ジャッジ日時 2023-09-15 14:25:04
合計ジャッジ時間 7,028 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,884 KB
testcase_01 AC 122 ms
55,988 KB
testcase_02 AC 123 ms
55,912 KB
testcase_03 AC 122 ms
55,628 KB
testcase_04 AC 124 ms
55,388 KB
testcase_05 AC 126 ms
55,576 KB
testcase_06 AC 125 ms
55,928 KB
testcase_07 AC 125 ms
55,708 KB
testcase_08 AC 127 ms
56,236 KB
testcase_09 AC 126 ms
55,644 KB
testcase_10 AC 128 ms
55,680 KB
testcase_11 AC 129 ms
55,680 KB
testcase_12 AC 125 ms
53,760 KB
testcase_13 AC 128 ms
55,660 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 131 ms
55,680 KB
testcase_17 WA -
testcase_18 AC 127 ms
55,440 KB
testcase_19 AC 126 ms
55,432 KB
testcase_20 WA -
testcase_21 AC 126 ms
55,716 KB
testcase_22 AC 126 ms
55,704 KB
testcase_23 AC 125 ms
55,836 KB
testcase_24 AC 125 ms
56,064 KB
testcase_25 AC 125 ms
56,088 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 124 ms
55,888 KB
testcase_29 AC 125 ms
55,788 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++;
    }
    if(s == 1) ans = Math.abs(a - s) + 1;
    System.out.println(ans);
  }
}
0