結果

問題 No.126 2基のエレベータ
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-25 18:19:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 727 bytes
コンパイル時間 3,422 ms
コンパイル使用メモリ 77,336 KB
実行使用メモリ 41,508 KB
最終ジャッジ日時 2024-04-19 01:49:58
合計ジャッジ時間 7,897 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
41,508 KB
testcase_01 AC 111 ms
41,280 KB
testcase_02 AC 115 ms
39,800 KB
testcase_03 AC 111 ms
41,492 KB
testcase_04 AC 110 ms
41,116 KB
testcase_05 AC 108 ms
40,136 KB
testcase_06 AC 125 ms
40,900 KB
testcase_07 AC 127 ms
41,172 KB
testcase_08 AC 121 ms
40,996 KB
testcase_09 AC 109 ms
40,500 KB
testcase_10 AC 121 ms
40,760 KB
testcase_11 AC 114 ms
40,972 KB
testcase_12 AC 124 ms
41,260 KB
testcase_13 AC 129 ms
41,184 KB
testcase_14 AC 120 ms
41,136 KB
testcase_15 AC 104 ms
39,384 KB
testcase_16 AC 108 ms
39,388 KB
testcase_17 AC 122 ms
40,980 KB
testcase_18 AC 125 ms
41,064 KB
testcase_19 AC 118 ms
40,660 KB
testcase_20 AC 126 ms
41,148 KB
testcase_21 AC 123 ms
41,068 KB
testcase_22 AC 122 ms
41,340 KB
testcase_23 AC 113 ms
40,828 KB
testcase_24 AC 119 ms
41,316 KB
testcase_25 AC 116 ms
40,916 KB
testcase_26 AC 112 ms
41,184 KB
testcase_27 AC 106 ms
39,608 KB
testcase_28 AC 119 ms
39,816 KB
testcase_29 AC 108 ms
39,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise126{
  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(a == b || s == 1 || s == a || Math.abs(s - a) <= Math.abs(s - b)){
      ans = Math.abs(s - a) + (s - 0);
    }else{
      if(a < b){
        if(a > 0){
          ans = Math.abs(s - b) + (s - a) + (a - 0);
        }else{
          ans = Math.abs(s - b) + (s - 1) + 2;
        }
      }else{
        if(s > a / 2){
          ans = Math.abs(s - b) + (a - s) + (a - 0);
        }else{
          ans = Math.abs(s - b) + (s - 1) + (a - 0);
        }
      }
    }
    System.out.println(ans);
	}
}
0