結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,960 KB
testcase_01 WA -
testcase_02 AC 119 ms
55,872 KB
testcase_03 AC 117 ms
56,088 KB
testcase_04 AC 116 ms
55,556 KB
testcase_05 AC 117 ms
55,824 KB
testcase_06 AC 116 ms
56,080 KB
testcase_07 WA -
testcase_08 AC 120 ms
55,780 KB
testcase_09 AC 119 ms
55,784 KB
testcase_10 AC 121 ms
55,864 KB
testcase_11 AC 119 ms
55,800 KB
testcase_12 AC 118 ms
55,492 KB
testcase_13 AC 117 ms
55,772 KB
testcase_14 AC 119 ms
55,896 KB
testcase_15 AC 119 ms
56,080 KB
testcase_16 AC 118 ms
55,536 KB
testcase_17 AC 118 ms
55,948 KB
testcase_18 AC 118 ms
55,488 KB
testcase_19 AC 118 ms
55,544 KB
testcase_20 AC 118 ms
55,492 KB
testcase_21 AC 118 ms
55,992 KB
testcase_22 AC 116 ms
56,076 KB
testcase_23 AC 121 ms
56,184 KB
testcase_24 AC 119 ms
55,832 KB
testcase_25 AC 118 ms
55,728 KB
testcase_26 AC 117 ms
55,900 KB
testcase_27 AC 119 ms
55,832 KB
testcase_28 AC 118 ms
55,960 KB
testcase_29 AC 119 ms
55,784 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{
			System.out.println(Math.min(Math.abs(b-c)+(c-1)+a, Math.abs(b-c)+Math.abs(a-c)+a));
		}
	}
}
0