結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
53,976 KB
testcase_01 AC 130 ms
54,296 KB
testcase_02 AC 124 ms
54,016 KB
testcase_03 AC 124 ms
54,044 KB
testcase_04 AC 117 ms
53,888 KB
testcase_05 AC 127 ms
54,340 KB
testcase_06 AC 110 ms
53,940 KB
testcase_07 AC 114 ms
52,800 KB
testcase_08 AC 122 ms
53,852 KB
testcase_09 AC 121 ms
54,252 KB
testcase_10 AC 117 ms
53,948 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 107 ms
52,828 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 122 ms
54,272 KB
testcase_17 WA -
testcase_18 AC 118 ms
53,832 KB
testcase_19 AC 119 ms
54,044 KB
testcase_20 WA -
testcase_21 AC 114 ms
53,868 KB
testcase_22 AC 126 ms
53,984 KB
testcase_23 AC 125 ms
54,092 KB
testcase_24 AC 113 ms
53,844 KB
testcase_25 AC 108 ms
52,712 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 115 ms
54,040 KB
testcase_29 AC 116 ms
53,992 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 - 1 + Math.abs(A - 1);
			ans += Math.min(t1, t2);
			System.out.println(ans);
		}
	}
}
0