結果

問題 No.126 2基のエレベータ
ユーザー tsunatama5tsunatama5
提出日時 2015-09-21 00:06:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 5,277 ms
コンパイル使用メモリ 74,216 KB
実行使用メモリ 57,972 KB
最終ジャッジ日時 2023-09-26 14:08:18
合計ジャッジ時間 11,233 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,576 KB
testcase_01 AC 120 ms
55,496 KB
testcase_02 WA -
testcase_03 AC 119 ms
55,872 KB
testcase_04 AC 119 ms
56,056 KB
testcase_05 AC 117 ms
55,532 KB
testcase_06 AC 119 ms
55,772 KB
testcase_07 AC 119 ms
55,600 KB
testcase_08 AC 121 ms
57,856 KB
testcase_09 AC 119 ms
55,712 KB
testcase_10 AC 119 ms
55,500 KB
testcase_11 AC 120 ms
55,624 KB
testcase_12 AC 120 ms
55,736 KB
testcase_13 AC 127 ms
55,252 KB
testcase_14 AC 116 ms
55,916 KB
testcase_15 AC 116 ms
53,996 KB
testcase_16 AC 125 ms
56,436 KB
testcase_17 AC 117 ms
55,684 KB
testcase_18 AC 118 ms
57,704 KB
testcase_19 AC 117 ms
55,748 KB
testcase_20 AC 117 ms
55,716 KB
testcase_21 AC 117 ms
55,496 KB
testcase_22 AC 121 ms
56,084 KB
testcase_23 AC 118 ms
55,912 KB
testcase_24 AC 119 ms
55,760 KB
testcase_25 AC 119 ms
56,008 KB
testcase_26 AC 119 ms
55,860 KB
testcase_27 AC 117 ms
55,780 KB
testcase_28 AC 118 ms
55,868 KB
testcase_29 AC 119 ms
55,896 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