結果

問題 No.126 2基のエレベータ
ユーザー 3pstn3pstn
提出日時 2015-01-25 15:47:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 562 bytes
コンパイル時間 2,643 ms
コンパイル使用メモリ 72,304 KB
実行使用メモリ 57,976 KB
最終ジャッジ日時 2023-09-05 06:13:18
合計ジャッジ時間 8,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,744 KB
testcase_01 AC 123 ms
55,756 KB
testcase_02 WA -
testcase_03 AC 121 ms
56,268 KB
testcase_04 AC 121 ms
55,520 KB
testcase_05 AC 121 ms
55,548 KB
testcase_06 AC 120 ms
55,816 KB
testcase_07 AC 120 ms
55,516 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 121 ms
55,940 KB
testcase_11 AC 122 ms
55,844 KB
testcase_12 AC 124 ms
56,000 KB
testcase_13 AC 121 ms
56,124 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 125 ms
56,320 KB
testcase_17 WA -
testcase_18 AC 123 ms
55,548 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 124 ms
56,040 KB
testcase_22 AC 121 ms
55,808 KB
testcase_23 AC 122 ms
55,752 KB
testcase_24 AC 124 ms
55,812 KB
testcase_25 AC 122 ms
56,012 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
55,820 KB
testcase_29 AC 123 ms
55,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
	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 sum = 0;

		if(Math.abs(a-s) < Math.abs(b-s)){
			// aの方が近い
			sum += Math.abs(a-s) + s;
		}else{
			// bの方が近い
			if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))){
				a++;
				sum++;
			}
			sum += Math.abs(b-s) + Math.abs(s-a) + a;
			// if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))) {
			// 	sum++;
			// }
		}
		System.out.println(sum);
	}
}
0