結果

問題 No.126 2基のエレベータ
ユーザー 37zigen37zigen
提出日時 2020-03-22 02:31:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 889 bytes
コンパイル時間 2,172 ms
コンパイル使用メモリ 78,080 KB
実行使用メモリ 42,020 KB
最終ジャッジ日時 2024-04-19 01:56:59
合計ジャッジ時間 7,166 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,448 KB
testcase_01 AC 127 ms
42,020 KB
testcase_02 AC 130 ms
41,424 KB
testcase_03 AC 130 ms
41,644 KB
testcase_04 AC 125 ms
40,340 KB
testcase_05 AC 126 ms
41,352 KB
testcase_06 AC 128 ms
41,688 KB
testcase_07 AC 129 ms
41,524 KB
testcase_08 AC 129 ms
41,568 KB
testcase_09 AC 128 ms
41,184 KB
testcase_10 AC 130 ms
41,740 KB
testcase_11 AC 125 ms
41,452 KB
testcase_12 AC 123 ms
41,764 KB
testcase_13 AC 128 ms
41,416 KB
testcase_14 AC 131 ms
41,448 KB
testcase_15 AC 129 ms
41,336 KB
testcase_16 AC 130 ms
41,208 KB
testcase_17 AC 127 ms
41,744 KB
testcase_18 AC 128 ms
41,592 KB
testcase_19 AC 128 ms
41,536 KB
testcase_20 AC 115 ms
41,676 KB
testcase_21 AC 128 ms
41,648 KB
testcase_22 AC 131 ms
41,524 KB
testcase_23 AC 129 ms
41,476 KB
testcase_24 AC 126 ms
41,624 KB
testcase_25 AC 124 ms
40,616 KB
testcase_26 AC 129 ms
41,172 KB
testcase_27 AC 130 ms
41,644 KB
testcase_28 AC 127 ms
41,708 KB
testcase_29 AC 124 ms
41,476 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();
		int ans=Integer.MAX_VALUE/3;
		if(S==1) {
			ans=Math.abs(A-S)+1;
		}else if(Math.abs(S-A)<=Math.abs(S-B)) {
			ans=Math.abs(S-A)+Math.abs(S-0);
		}else {
			if(A>0) {
				ans=Math.abs(S-B)+Math.abs(A-S)+Math.abs(A);
			}else {
				ans=Math.abs(S-B)+Math.abs(S-1)+2;
			}
		}
		ans=Math.min(ans, Math.abs(S-B)+Math.abs(S-1)+Math.abs(A-1)+1);
		System.out.println(ans);
	}


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

}
0