結果

問題 No.126 2基のエレベータ
ユーザー YamaKasaYamaKasa
提出日時 2018-07-14 15:39:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 74,720 KB
実行使用メモリ 41,892 KB
最終ジャッジ日時 2024-04-18 11:41:34
合計ジャッジ時間 6,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,068 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 116 ms
41,416 KB
testcase_04 AC 100 ms
40,484 KB
testcase_05 WA -
testcase_06 AC 106 ms
41,176 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 103 ms
41,304 KB
testcase_11 AC 113 ms
41,484 KB
testcase_12 AC 109 ms
41,224 KB
testcase_13 AC 118 ms
41,144 KB
testcase_14 AC 120 ms
41,372 KB
testcase_15 AC 108 ms
41,020 KB
testcase_16 AC 119 ms
41,584 KB
testcase_17 AC 118 ms
41,156 KB
testcase_18 AC 116 ms
40,016 KB
testcase_19 WA -
testcase_20 AC 119 ms
41,540 KB
testcase_21 AC 110 ms
40,980 KB
testcase_22 AC 115 ms
40,252 KB
testcase_23 AC 119 ms
41,356 KB
testcase_24 AC 108 ms
41,540 KB
testcase_25 AC 123 ms
41,512 KB
testcase_26 AC 118 ms
40,076 KB
testcase_27 AC 110 ms
41,476 KB
testcase_28 AC 118 ms
41,428 KB
testcase_29 AC 106 ms
41,300 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 >= S) {
				if(A - S >= S) {
					ans += S + A - 1;
				}else {
					ans += A - S + A;
				}
			}else {
				ans += S - A + A;
			}
			System.out.println(ans);
		}
	}
}
0