結果

問題 No.126 2基のエレベータ
ユーザー tsunatama5tsunatama5
提出日時 2015-02-08 14:47:01
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 835 bytes
コンパイル時間 3,936 ms
コンパイル使用メモリ 78,192 KB
実行使用メモリ 41,664 KB
最終ジャッジ日時 2024-05-01 14:50:55
合計ジャッジ時間 7,219 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
41,256 KB
testcase_01 AC 102 ms
41,316 KB
testcase_02 WA -
testcase_03 AC 111 ms
41,348 KB
testcase_04 AC 108 ms
41,444 KB
testcase_05 AC 116 ms
41,432 KB
testcase_06 AC 104 ms
41,104 KB
testcase_07 AC 102 ms
41,388 KB
testcase_08 AC 101 ms
40,920 KB
testcase_09 AC 103 ms
41,140 KB
testcase_10 AC 103 ms
41,396 KB
testcase_11 AC 117 ms
41,664 KB
testcase_12 AC 101 ms
41,532 KB
testcase_13 AC 104 ms
41,652 KB
testcase_14 AC 117 ms
41,524 KB
testcase_15 AC 112 ms
41,412 KB
testcase_16 AC 113 ms
41,600 KB
testcase_17 AC 99 ms
41,512 KB
testcase_18 AC 99 ms
41,424 KB
testcase_19 AC 114 ms
41,268 KB
testcase_20 AC 100 ms
41,296 KB
testcase_21 AC 99 ms
41,340 KB
testcase_22 AC 117 ms
41,176 KB
testcase_23 AC 119 ms
41,568 KB
testcase_24 AC 102 ms
41,384 KB
testcase_25 AC 110 ms
40,956 KB
testcase_26 AC 103 ms
41,444 KB
testcase_27 AC 109 ms
41,328 KB
testcase_28 AC 99 ms
41,300 KB
testcase_29 AC 109 ms
41,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package P126;

import java.util.Scanner;

public class P126 {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String r = sc.nextLine();
		String[] rstrs = r.split(" ",0);

		int a = Integer.parseInt(rstrs[0]);
		int b = Integer.parseInt(rstrs[1]);
		int s = Integer.parseInt(rstrs[2]);
		int ans = 0;
		
		if (Math.abs(s-a) <= Math.abs(s-b)) {
			ans = Math.abs(s-a) + (s-0);
		} else if (Math.abs(s-a) > Math.abs(s-b) && a == 0) {
			ans = Math.abs(s-b) + Math.abs(s-1) + Math.abs(a-1) + Math.abs(1-a);
		} else if ((Math.abs(s-a) > Math.abs(s-b) && a != 0)){
			if (Math.abs(s-a)<Math.abs(s-1)) {
				ans = Math.abs(s-b) + Math.abs(s-a) + Math.abs(a);
			} else if (Math.abs(s-a)>=Math.abs(s-1)){
				ans = Math.abs(s-b) + Math.abs(s-1) + Math.abs(a);
			}
		}
		
		System.out.println(ans);
	}
}
0