結果

問題 No.126 2基のエレベータ
ユーザー kanra661kanra661
提出日時 2015-01-14 00:37:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 7,025 ms
コンパイル使用メモリ 71,852 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-09-04 12:42:37
合計ジャッジ時間 9,913 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,696 KB
testcase_01 AC 123 ms
56,136 KB
testcase_02 AC 123 ms
56,296 KB
testcase_03 AC 123 ms
55,788 KB
testcase_04 AC 123 ms
55,772 KB
testcase_05 AC 125 ms
55,696 KB
testcase_06 AC 124 ms
55,804 KB
testcase_07 AC 123 ms
55,492 KB
testcase_08 AC 124 ms
55,784 KB
testcase_09 AC 123 ms
55,992 KB
testcase_10 AC 124 ms
55,792 KB
testcase_11 AC 123 ms
55,684 KB
testcase_12 AC 123 ms
55,752 KB
testcase_13 AC 123 ms
55,784 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 123 ms
55,772 KB
testcase_17 WA -
testcase_18 AC 123 ms
55,488 KB
testcase_19 AC 126 ms
56,048 KB
testcase_20 WA -
testcase_21 AC 124 ms
55,800 KB
testcase_22 AC 125 ms
55,524 KB
testcase_23 AC 123 ms
55,784 KB
testcase_24 AC 125 ms
55,732 KB
testcase_25 AC 125 ms
55,804 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
56,144 KB
testcase_29 AC 125 ms
53,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No_126 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int s = sc.nextInt();
		int move = 0;
		sc.close();

		int dis_a = 0;
		int dis_b = 0;
		if (a == 0) {
			move += 1;
			a += 1;
		}
		dis_a = Math.abs(a - s);
		dis_b = Math.abs(b - s);

		if (s == 1 || dis_b >= dis_a) {
			move += dis_a + s;
		} else if (a == 0) {
			move += (b - 1) + 2;
		} else {
			move += Math.min(dis_b+s+a, dis_b+a+dis_a);
		}
		System.out.println(move);
	}

}
0