結果

問題 No.126 2基のエレベータ
ユーザー kuramubonnkuramubonn
提出日時 2023-02-04 15:54:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 492 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 71,304 KB
実行使用メモリ 56,772 KB
最終ジャッジ日時 2023-09-16 12:31:23
合計ジャッジ時間 7,096 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,704 KB
testcase_01 AC 121 ms
56,332 KB
testcase_02 AC 119 ms
55,960 KB
testcase_03 AC 122 ms
55,704 KB
testcase_04 AC 120 ms
56,096 KB
testcase_05 AC 124 ms
55,988 KB
testcase_06 AC 124 ms
56,028 KB
testcase_07 AC 123 ms
55,916 KB
testcase_08 AC 128 ms
55,668 KB
testcase_09 AC 129 ms
56,436 KB
testcase_10 AC 124 ms
55,836 KB
testcase_11 AC 120 ms
55,736 KB
testcase_12 AC 121 ms
55,904 KB
testcase_13 AC 121 ms
55,756 KB
testcase_14 AC 120 ms
55,604 KB
testcase_15 AC 119 ms
55,628 KB
testcase_16 AC 127 ms
56,120 KB
testcase_17 AC 126 ms
56,076 KB
testcase_18 AC 125 ms
56,772 KB
testcase_19 AC 126 ms
55,924 KB
testcase_20 AC 127 ms
55,864 KB
testcase_21 AC 129 ms
56,056 KB
testcase_22 AC 126 ms
56,036 KB
testcase_23 AC 129 ms
55,768 KB
testcase_24 AC 129 ms
55,948 KB
testcase_25 AC 126 ms
55,888 KB
testcase_26 AC 126 ms
56,036 KB
testcase_27 AC 124 ms
55,712 KB
testcase_28 AC 125 ms
55,952 KB
testcase_29 AC 124 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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