結果

問題 No.126 2基のエレベータ
ユーザー YamaKasaYamaKasa
提出日時 2018-07-14 15:10:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 2,441 ms
コンパイル使用メモリ 76,816 KB
実行使用メモリ 42,012 KB
最終ジャッジ日時 2024-04-18 10:07:53
合計ジャッジ時間 7,573 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 138 ms
41,344 KB
testcase_02 AC 131 ms
41,196 KB
testcase_03 AC 123 ms
41,076 KB
testcase_04 AC 120 ms
41,392 KB
testcase_05 AC 118 ms
42,012 KB
testcase_06 AC 140 ms
41,340 KB
testcase_07 AC 130 ms
41,672 KB
testcase_08 AC 127 ms
41,388 KB
testcase_09 AC 108 ms
41,232 KB
testcase_10 AC 119 ms
40,224 KB
testcase_11 AC 112 ms
41,336 KB
testcase_12 AC 119 ms
41,044 KB
testcase_13 AC 127 ms
41,164 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 131 ms
41,628 KB
testcase_19 AC 107 ms
40,932 KB
testcase_20 WA -
testcase_21 AC 132 ms
41,428 KB
testcase_22 AC 134 ms
41,488 KB
testcase_23 AC 134 ms
41,204 KB
testcase_24 AC 134 ms
41,520 KB
testcase_25 AC 132 ms
41,480 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 132 ms
41,268 KB
testcase_29 AC 133 ms
41,216 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 t1, t2;
		if(A == 0) {
			t1 = S + S;
			if(S - B > 0) {
				t2 = S - B + S + 1;
			}else {
				t2 = B - S + S + 1;
			}
			System.out.println(Math.min(t1, t2));
			System.exit(0);
		}
		if(S - A > 0) {
			t1 = S - A + S ;
		}else {
			t1 = A - S + S ;
		}
		if(S - B > 0) {
			t2 = S - B;
			if(S - A > 0) {
				t2 += S - A + A;
			}else {
				t2 += A - S + A ;
			}
		}else {
			t2 = B - S;
			if(S - A > 0) {
				t2 += S - A + A;
			}else {
				t2 += A - S + A ;
			}
		}
		int ans = Math.min(t1, t2);
		System.out.println(ans);
	}
}
0