結果

問題 No.126 2基のエレベータ
ユーザー tsunabittsunabit
提出日時 2020-03-03 21:58:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 457 bytes
コンパイル時間 3,438 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 41,736 KB
最終ジャッジ日時 2024-04-19 01:56:25
合計ジャッジ時間 8,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,460 KB
testcase_01 AC 131 ms
41,164 KB
testcase_02 AC 129 ms
41,352 KB
testcase_03 AC 130 ms
41,580 KB
testcase_04 AC 129 ms
41,160 KB
testcase_05 AC 127 ms
41,524 KB
testcase_06 AC 130 ms
41,400 KB
testcase_07 AC 128 ms
41,592 KB
testcase_08 AC 127 ms
41,508 KB
testcase_09 AC 125 ms
41,652 KB
testcase_10 AC 131 ms
41,560 KB
testcase_11 AC 130 ms
41,280 KB
testcase_12 AC 131 ms
41,444 KB
testcase_13 AC 135 ms
41,324 KB
testcase_14 AC 128 ms
41,384 KB
testcase_15 AC 126 ms
41,496 KB
testcase_16 AC 127 ms
41,352 KB
testcase_17 AC 126 ms
41,736 KB
testcase_18 AC 118 ms
40,280 KB
testcase_19 AC 116 ms
41,580 KB
testcase_20 AC 132 ms
41,196 KB
testcase_21 AC 130 ms
41,528 KB
testcase_22 AC 131 ms
41,620 KB
testcase_23 AC 131 ms
41,364 KB
testcase_24 AC 133 ms
41,216 KB
testcase_25 AC 128 ms
41,132 KB
testcase_26 AC 118 ms
39,996 KB
testcase_27 AC 131 ms
41,456 KB
testcase_28 AC 126 ms
41,124 KB
testcase_29 AC 128 ms
41,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No126 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), s = sc.nextInt();
		if(Math.abs(a-s) <= Math.abs(b-s) || s == 1) {
			System.out.println(Math.abs(a-s) + s);
		}else {
			System.out.println(Math.min(Math.abs(b-s) + (s-1) + Math.abs(a-1) + 1, Math.abs(b-s) + Math.abs(a-s) + Math.abs(a-1) + 1));
		}
	}
}
0