結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,764 KB
testcase_01 AC 121 ms
55,944 KB
testcase_02 WA -
testcase_03 AC 118 ms
56,120 KB
testcase_04 AC 118 ms
55,764 KB
testcase_05 AC 121 ms
55,516 KB
testcase_06 AC 120 ms
56,064 KB
testcase_07 AC 120 ms
55,900 KB
testcase_08 AC 119 ms
56,016 KB
testcase_09 AC 117 ms
55,852 KB
testcase_10 AC 122 ms
55,760 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 121 ms
55,660 KB
testcase_14 AC 121 ms
56,012 KB
testcase_15 AC 119 ms
55,916 KB
testcase_16 AC 119 ms
56,240 KB
testcase_17 AC 119 ms
55,864 KB
testcase_18 AC 120 ms
55,800 KB
testcase_19 AC 121 ms
55,752 KB
testcase_20 AC 121 ms
56,004 KB
testcase_21 AC 120 ms
55,752 KB
testcase_22 AC 120 ms
56,036 KB
testcase_23 AC 121 ms
56,292 KB
testcase_24 AC 120 ms
55,884 KB
testcase_25 AC 120 ms
55,748 KB
testcase_26 AC 119 ms
55,524 KB
testcase_27 AC 120 ms
55,700 KB
testcase_28 AC 121 ms
55,992 KB
testcase_29 AC 121 ms
58,356 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)){
			if (Math.abs(s-a)<Math.abs(s-1)) {
				ans = Math.abs(s-b) + Math.abs(s-a) + Math.abs(a);
			} else if (Math.abs(s-a)>Math.abs(s-1)){
				ans = Math.abs(s-b) + Math.abs(s-1) + Math.abs(a);
			}
		}
		
		System.out.println(ans);
	}
}
0