結果

問題 No.126 2基のエレベータ
ユーザー kou6839kou6839
提出日時 2015-02-24 19:31:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 465 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 74,828 KB
実行使用メモリ 41,600 KB
最終ジャッジ日時 2024-04-19 01:43:30
合計ジャッジ時間 6,383 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
39,644 KB
testcase_01 AC 126 ms
41,460 KB
testcase_02 AC 133 ms
41,248 KB
testcase_03 AC 128 ms
41,188 KB
testcase_04 AC 130 ms
40,836 KB
testcase_05 AC 132 ms
41,020 KB
testcase_06 AC 125 ms
41,084 KB
testcase_07 AC 120 ms
41,152 KB
testcase_08 AC 109 ms
40,976 KB
testcase_09 AC 106 ms
39,796 KB
testcase_10 AC 114 ms
41,144 KB
testcase_11 AC 113 ms
40,892 KB
testcase_12 AC 113 ms
40,852 KB
testcase_13 AC 103 ms
40,384 KB
testcase_14 AC 122 ms
40,880 KB
testcase_15 AC 125 ms
41,024 KB
testcase_16 AC 115 ms
40,920 KB
testcase_17 AC 126 ms
40,828 KB
testcase_18 AC 111 ms
39,836 KB
testcase_19 AC 103 ms
39,828 KB
testcase_20 AC 117 ms
40,840 KB
testcase_21 AC 116 ms
40,960 KB
testcase_22 AC 102 ms
39,936 KB
testcase_23 AC 118 ms
41,600 KB
testcase_24 AC 113 ms
40,896 KB
testcase_25 AC 109 ms
39,956 KB
testcase_26 AC 111 ms
40,992 KB
testcase_27 AC 105 ms
40,088 KB
testcase_28 AC 116 ms
40,876 KB
testcase_29 AC 122 ms
41,348 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.abs(b-c)+(c-1)+2);
		}
	}
}
0