結果

問題 No.126 2基のエレベータ
ユーザー tsunatama5tsunatama5
提出日時 2015-02-08 13:54:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 5,479 ms
コンパイル使用メモリ 74,696 KB
実行使用メモリ 58,016 KB
最終ジャッジ日時 2023-09-05 15:23:39
合計ジャッジ時間 8,763 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 121 ms
55,704 KB
testcase_04 AC 125 ms
55,484 KB
testcase_05 WA -
testcase_06 AC 131 ms
55,704 KB
testcase_07 WA -
testcase_08 AC 127 ms
55,504 KB
testcase_09 AC 126 ms
55,544 KB
testcase_10 AC 128 ms
55,320 KB
testcase_11 AC 127 ms
55,856 KB
testcase_12 AC 126 ms
55,532 KB
testcase_13 AC 126 ms
56,004 KB
testcase_14 AC 124 ms
55,916 KB
testcase_15 AC 126 ms
55,668 KB
testcase_16 WA -
testcase_17 AC 128 ms
57,568 KB
testcase_18 AC 125 ms
55,536 KB
testcase_19 AC 122 ms
55,568 KB
testcase_20 AC 121 ms
55,788 KB
testcase_21 AC 122 ms
55,756 KB
testcase_22 AC 120 ms
55,748 KB
testcase_23 AC 122 ms
55,820 KB
testcase_24 AC 121 ms
55,660 KB
testcase_25 AC 121 ms
55,908 KB
testcase_26 AC 121 ms
55,708 KB
testcase_27 AC 121 ms
55,912 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package P126;

import java.util.Scanner;

public class P126 {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String r = sc.nextLine();
		String[] rstrs = r.split(" ",0);

		int a = Integer.parseInt(rstrs[0]);
		int b = Integer.parseInt(rstrs[1]);
		int s = Integer.parseInt(rstrs[2]);
		int ans = 0;
		
		if (Math.abs(s-a) <= Math.abs(s-b)) {
			ans = Math.abs(s-a) + (s-0);
		} else if (Math.abs(s-a) > Math.abs(s-b) && a >= 1) {
			ans = Math.abs(s-b) + Math.abs(s-1) + Math.abs(a-1) + 1;
		} else if ((Math.abs(s-a) > Math.abs(s-b) && a == 1)){
			ans = Math.abs(s-b) + Math.abs(s-1) + 2;
		}
		
		System.out.println(ans);
	}
}
0