結果

問題 No.126 2基のエレベータ
ユーザー 3pstn3pstn
提出日時 2015-01-25 15:38:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 3,909 ms
コンパイル使用メモリ 71,720 KB
実行使用メモリ 56,332 KB
最終ジャッジ日時 2023-09-05 06:12:22
合計ジャッジ時間 8,329 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,836 KB
testcase_01 AC 122 ms
55,812 KB
testcase_02 WA -
testcase_03 AC 121 ms
55,692 KB
testcase_04 AC 123 ms
55,696 KB
testcase_05 AC 122 ms
56,208 KB
testcase_06 AC 122 ms
56,332 KB
testcase_07 AC 122 ms
55,776 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 121 ms
55,920 KB
testcase_11 AC 125 ms
55,900 KB
testcase_12 AC 121 ms
56,052 KB
testcase_13 AC 122 ms
55,956 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 122 ms
55,924 KB
testcase_17 WA -
testcase_18 AC 122 ms
55,764 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 124 ms
55,784 KB
testcase_22 AC 126 ms
55,884 KB
testcase_23 AC 122 ms
55,912 KB
testcase_24 AC 121 ms
55,996 KB
testcase_25 AC 123 ms
56,060 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 121 ms
56,084 KB
testcase_29 AC 122 ms
55,512 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 sum = 0;

		if(Math.abs(a-s) < Math.abs(b-s)){
			// aの方が近い
			sum += Math.abs(a-s) + s;
		}else{
			// bの方が近い
			sum += Math.abs(b-s) + Math.abs(s-a) + a;
			if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}
0