結果

問題 No.126 2基のエレベータ
ユーザー 37zigen37zigen
提出日時 2020-03-22 02:26:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 75,032 KB
実行使用メモリ 58,060 KB
最終ジャッジ日時 2023-08-25 21:05:59
合計ジャッジ時間 7,438 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,248 KB
testcase_01 AC 120 ms
56,308 KB
testcase_02 AC 119 ms
56,108 KB
testcase_03 AC 119 ms
55,884 KB
testcase_04 AC 118 ms
54,172 KB
testcase_05 AC 119 ms
55,944 KB
testcase_06 AC 119 ms
55,872 KB
testcase_07 AC 119 ms
55,880 KB
testcase_08 AC 121 ms
56,432 KB
testcase_09 AC 122 ms
56,344 KB
testcase_10 AC 119 ms
56,564 KB
testcase_11 AC 118 ms
55,652 KB
testcase_12 AC 120 ms
56,188 KB
testcase_13 AC 119 ms
56,236 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 123 ms
54,272 KB
testcase_17 WA -
testcase_18 AC 120 ms
56,376 KB
testcase_19 AC 121 ms
56,336 KB
testcase_20 WA -
testcase_21 AC 119 ms
55,964 KB
testcase_22 AC 119 ms
56,444 KB
testcase_23 AC 120 ms
56,384 KB
testcase_24 AC 120 ms
56,152 KB
testcase_25 AC 121 ms
56,396 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 121 ms
56,204 KB
testcase_29 AC 120 ms
55,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int S=sc.nextInt();
		if(S==1) {
			System.out.println(Math.abs(A-S)+1);
		}else if(Math.abs(S-A)<=Math.abs(S-B)) {
			System.out.println(Math.abs(S-A)+Math.abs(S-0));
		}else {
			if(A>0) {
				System.out.println(Math.abs(S-B)+Math.abs(A-S)+Math.abs(A));
			}else {
				System.out.println(Math.abs(S-B)+Math.abs(S-1)+2);
			}
		}
	}


	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0