結果

問題 No.126 2基のエレベータ
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-19 17:54:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 4,437 ms
コンパイル使用メモリ 73,244 KB
実行使用メモリ 56,192 KB
最終ジャッジ日時 2023-09-22 17:57:44
合計ジャッジ時間 11,035 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
55,868 KB
testcase_01 WA -
testcase_02 AC 142 ms
56,100 KB
testcase_03 AC 136 ms
55,768 KB
testcase_04 AC 138 ms
55,888 KB
testcase_05 AC 138 ms
55,588 KB
testcase_06 AC 140 ms
55,860 KB
testcase_07 WA -
testcase_08 AC 141 ms
55,592 KB
testcase_09 AC 152 ms
55,824 KB
testcase_10 AC 143 ms
55,796 KB
testcase_11 AC 142 ms
55,772 KB
testcase_12 AC 142 ms
55,828 KB
testcase_13 AC 143 ms
56,088 KB
testcase_14 AC 143 ms
55,816 KB
testcase_15 AC 139 ms
55,800 KB
testcase_16 AC 141 ms
55,768 KB
testcase_17 AC 139 ms
55,816 KB
testcase_18 AC 138 ms
55,812 KB
testcase_19 AC 139 ms
55,460 KB
testcase_20 AC 137 ms
55,828 KB
testcase_21 AC 138 ms
55,592 KB
testcase_22 AC 135 ms
55,800 KB
testcase_23 AC 135 ms
55,524 KB
testcase_24 AC 136 ms
55,772 KB
testcase_25 AC 137 ms
55,708 KB
testcase_26 AC 133 ms
55,452 KB
testcase_27 AC 142 ms
55,804 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();
		int l = 0; //距離
		if(S == 0) {
			System.out.println(0);
			return;
		}
		if(S == 1) {
			System.out.println(Math.abs(A-S) + S);
			return;
		}
		
		if(Math.abs(A-S) <= Math.abs(B-S)) {
			System.out.println(Math.abs(A-S) + S);
		}else if(Math.abs(S-1) <= Math.abs(S-A)) {
			System.out.println(Math.abs(S-B)+S-1+A);
		}
		else {
				System.out.println(Math.abs(A-B)+A);
		}
		
	}
}
0