結果

問題 No.126 2基のエレベータ
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-07-04 10:17:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 3,688 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 41,292 KB
最終ジャッジ日時 2024-04-19 01:53:10
合計ジャッジ時間 7,586 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
39,852 KB
testcase_01 AC 109 ms
40,404 KB
testcase_02 AC 107 ms
40,112 KB
testcase_03 AC 104 ms
39,824 KB
testcase_04 AC 118 ms
41,088 KB
testcase_05 AC 117 ms
41,212 KB
testcase_06 AC 109 ms
40,088 KB
testcase_07 AC 125 ms
40,900 KB
testcase_08 AC 115 ms
40,796 KB
testcase_09 AC 124 ms
40,888 KB
testcase_10 AC 115 ms
41,288 KB
testcase_11 AC 108 ms
39,812 KB
testcase_12 AC 127 ms
41,292 KB
testcase_13 AC 108 ms
39,604 KB
testcase_14 AC 123 ms
41,100 KB
testcase_15 AC 113 ms
40,792 KB
testcase_16 AC 105 ms
39,740 KB
testcase_17 AC 116 ms
40,132 KB
testcase_18 AC 106 ms
40,088 KB
testcase_19 AC 117 ms
41,272 KB
testcase_20 AC 127 ms
41,232 KB
testcase_21 AC 123 ms
41,264 KB
testcase_22 AC 124 ms
40,052 KB
testcase_23 AC 122 ms
41,292 KB
testcase_24 AC 116 ms
40,800 KB
testcase_25 AC 119 ms
41,276 KB
testcase_26 AC 119 ms
40,780 KB
testcase_27 AC 113 ms
41,148 KB
testcase_28 AC 111 ms
40,572 KB
testcase_29 AC 115 ms
41,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No126{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int s = sc.nextInt();

		if(s == 1){
			System.out.println(Math.abs(s-a)+s);
			return;
		}
		if(Math.abs(s-a) <= Math.abs(s-b)){
			System.out.println(Math.abs(s-a)+s);
		}else{
			if(Math.abs(a-s) <= (s-1)){
				System.out.println(Math.abs(s-b)+Math.abs(a-s)+a);
			}else{
				System.out.println(Math.abs(s-b)+(s-1)+Math.abs(a-1)+1);
			}
		}
	}
}
0