結果

問題 No.126 2基のエレベータ
ユーザー kanra661kanra661
提出日時 2015-01-14 01:05:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 3,457 ms
コンパイル使用メモリ 74,404 KB
実行使用メモリ 41,648 KB
最終ジャッジ日時 2024-04-19 01:40:34
合計ジャッジ時間 8,080 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,420 KB
testcase_01 AC 126 ms
41,304 KB
testcase_02 AC 126 ms
41,648 KB
testcase_03 AC 126 ms
41,248 KB
testcase_04 AC 125 ms
41,484 KB
testcase_05 AC 115 ms
39,996 KB
testcase_06 AC 129 ms
41,400 KB
testcase_07 AC 127 ms
41,560 KB
testcase_08 AC 129 ms
41,380 KB
testcase_09 AC 127 ms
41,376 KB
testcase_10 AC 122 ms
41,200 KB
testcase_11 AC 110 ms
40,256 KB
testcase_12 AC 112 ms
40,336 KB
testcase_13 AC 127 ms
41,500 KB
testcase_14 AC 126 ms
41,280 KB
testcase_15 AC 112 ms
40,332 KB
testcase_16 AC 125 ms
41,480 KB
testcase_17 AC 123 ms
41,552 KB
testcase_18 AC 120 ms
41,152 KB
testcase_19 AC 113 ms
40,320 KB
testcase_20 AC 116 ms
39,900 KB
testcase_21 AC 131 ms
41,148 KB
testcase_22 AC 107 ms
39,740 KB
testcase_23 AC 111 ms
40,312 KB
testcase_24 AC 124 ms
41,116 KB
testcase_25 AC 123 ms
41,648 KB
testcase_26 AC 124 ms
41,376 KB
testcase_27 AC 112 ms
40,368 KB
testcase_28 AC 127 ms
41,256 KB
testcase_29 AC 116 ms
40,852 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;
		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 += dis_b + s + 1;
		} else {
			move += Math.min(dis_b+s+a-1, dis_b+a+dis_a);
		}
		System.out.println(move);
	}

}
0