結果

問題 No.126 2基のエレベータ
ユーザー kou6839kou6839
提出日時 2015-02-24 19:26:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 71,556 KB
実行使用メモリ 56,456 KB
最終ジャッジ日時 2023-09-06 04:14:52
合計ジャッジ時間 6,740 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,856 KB
testcase_01 WA -
testcase_02 AC 118 ms
55,776 KB
testcase_03 AC 119 ms
54,152 KB
testcase_04 AC 121 ms
55,744 KB
testcase_05 AC 118 ms
56,000 KB
testcase_06 AC 119 ms
55,788 KB
testcase_07 WA -
testcase_08 AC 117 ms
55,952 KB
testcase_09 AC 118 ms
55,812 KB
testcase_10 AC 133 ms
55,948 KB
testcase_11 AC 119 ms
56,184 KB
testcase_12 AC 122 ms
55,820 KB
testcase_13 AC 117 ms
55,536 KB
testcase_14 AC 119 ms
56,140 KB
testcase_15 AC 118 ms
56,056 KB
testcase_16 AC 118 ms
56,036 KB
testcase_17 AC 119 ms
55,824 KB
testcase_18 AC 120 ms
55,860 KB
testcase_19 AC 122 ms
55,728 KB
testcase_20 AC 122 ms
56,456 KB
testcase_21 AC 119 ms
55,512 KB
testcase_22 AC 120 ms
55,748 KB
testcase_23 AC 120 ms
55,960 KB
testcase_24 AC 125 ms
55,892 KB
testcase_25 AC 121 ms
56,040 KB
testcase_26 AC 116 ms
53,896 KB
testcase_27 AC 122 ms
55,732 KB
testcase_28 AC 120 ms
55,780 KB
testcase_29 AC 117 ms
55,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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