結果

問題 No.126 2基のエレベータ
ユーザー tentententen
提出日時 2020-10-15 18:39:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 2,878 ms
コンパイル使用メモリ 71,436 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2023-09-28 01:15:16
合計ジャッジ時間 8,351 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,692 KB
testcase_01 AC 127 ms
55,616 KB
testcase_02 AC 129 ms
55,888 KB
testcase_03 AC 127 ms
56,196 KB
testcase_04 AC 126 ms
55,740 KB
testcase_05 AC 127 ms
55,664 KB
testcase_06 AC 127 ms
55,936 KB
testcase_07 AC 127 ms
55,700 KB
testcase_08 AC 126 ms
55,392 KB
testcase_09 AC 128 ms
55,548 KB
testcase_10 AC 127 ms
55,888 KB
testcase_11 AC 127 ms
55,804 KB
testcase_12 AC 127 ms
55,932 KB
testcase_13 AC 124 ms
55,696 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 125 ms
55,704 KB
testcase_17 WA -
testcase_18 AC 125 ms
55,644 KB
testcase_19 AC 124 ms
55,752 KB
testcase_20 WA -
testcase_21 AC 125 ms
55,560 KB
testcase_22 AC 124 ms
55,624 KB
testcase_23 AC 125 ms
55,432 KB
testcase_24 AC 124 ms
55,800 KB
testcase_25 AC 126 ms
54,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
55,868 KB
testcase_29 AC 126 ms
55,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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