結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,504 KB
testcase_01 AC 132 ms
55,936 KB
testcase_02 WA -
testcase_03 AC 122 ms
56,132 KB
testcase_04 AC 124 ms
55,720 KB
testcase_05 AC 125 ms
55,736 KB
testcase_06 AC 126 ms
56,012 KB
testcase_07 AC 122 ms
55,604 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 123 ms
56,048 KB
testcase_11 AC 121 ms
56,156 KB
testcase_12 AC 121 ms
55,792 KB
testcase_13 AC 124 ms
55,812 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 122 ms
55,776 KB
testcase_17 WA -
testcase_18 AC 120 ms
56,008 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 122 ms
56,332 KB
testcase_22 AC 124 ms
55,656 KB
testcase_23 AC 121 ms
56,012 KB
testcase_24 AC 122 ms
56,100 KB
testcase_25 AC 122 ms
56,068 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 124 ms
56,096 KB
testcase_29 AC 123 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) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}
0