結果

問題 No.126 2基のエレベータ
ユーザー tsunatama5tsunatama5
提出日時 2015-02-08 14:33:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 3,423 ms
コンパイル使用メモリ 78,348 KB
実行使用メモリ 58,180 KB
最終ジャッジ日時 2023-09-05 15:26:02
合計ジャッジ時間 8,411 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,592 KB
testcase_01 AC 120 ms
55,512 KB
testcase_02 WA -
testcase_03 AC 121 ms
55,784 KB
testcase_04 AC 121 ms
55,384 KB
testcase_05 AC 121 ms
55,936 KB
testcase_06 AC 122 ms
55,792 KB
testcase_07 AC 121 ms
55,660 KB
testcase_08 AC 118 ms
56,140 KB
testcase_09 AC 122 ms
55,864 KB
testcase_10 AC 121 ms
55,828 KB
testcase_11 AC 119 ms
55,976 KB
testcase_12 AC 117 ms
55,924 KB
testcase_13 AC 118 ms
55,700 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 120 ms
55,756 KB
testcase_17 WA -
testcase_18 AC 120 ms
55,816 KB
testcase_19 AC 120 ms
55,696 KB
testcase_20 WA -
testcase_21 AC 119 ms
55,612 KB
testcase_22 AC 119 ms
55,912 KB
testcase_23 AC 121 ms
55,852 KB
testcase_24 AC 119 ms
55,956 KB
testcase_25 AC 118 ms
55,952 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 120 ms
55,948 KB
testcase_29 AC 122 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

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