結果

問題 No.126 2基のエレベータ
ユーザー YamaKasaYamaKasa
提出日時 2018-07-14 15:53:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 54,276 KB
最終ジャッジ日時 2024-04-18 11:59:33
合計ジャッジ時間 6,178 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
53,828 KB
testcase_01 AC 117 ms
54,276 KB
testcase_02 WA -
testcase_03 AC 115 ms
53,956 KB
testcase_04 AC 114 ms
53,888 KB
testcase_05 AC 117 ms
54,236 KB
testcase_06 AC 119 ms
53,984 KB
testcase_07 AC 115 ms
54,008 KB
testcase_08 AC 101 ms
52,748 KB
testcase_09 AC 114 ms
54,192 KB
testcase_10 AC 100 ms
52,776 KB
testcase_11 AC 106 ms
53,412 KB
testcase_12 AC 110 ms
53,644 KB
testcase_13 AC 112 ms
53,860 KB
testcase_14 AC 115 ms
53,956 KB
testcase_15 AC 121 ms
54,144 KB
testcase_16 AC 117 ms
54,144 KB
testcase_17 AC 111 ms
52,840 KB
testcase_18 AC 109 ms
52,828 KB
testcase_19 AC 120 ms
54,104 KB
testcase_20 AC 116 ms
54,216 KB
testcase_21 AC 122 ms
53,988 KB
testcase_22 AC 107 ms
52,684 KB
testcase_23 AC 117 ms
53,948 KB
testcase_24 AC 110 ms
53,928 KB
testcase_25 AC 100 ms
52,904 KB
testcase_26 AC 119 ms
53,924 KB
testcase_27 AC 107 ms
52,980 KB
testcase_28 AC 110 ms
52,892 KB
testcase_29 AC 114 ms
53,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int S = scan.nextInt();
		scan.close();
		int l1 = Math.abs(S - A);
		int l2 = Math.abs(S - B);
		if(l1 <= l2) {
			int ans = l1 + S;
			System.out.println(ans);
		}else {
			int ans = l2;
			if(A == 0) {
				ans += 2 + S - 1;
				System.out.println(ans);
				System.exit(0);
			}
			int t1 = l1 + A;
			int t2 = S + Math.abs(A - 1);
			ans += Math.min(t1, t2);
			System.out.println(ans);
		}
	}
}
0