結果

問題 No.126 2基のエレベータ
ユーザー kanra661kanra661
提出日時 2015-01-14 00:12:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 3,950 ms
コンパイル使用メモリ 72,484 KB
実行使用メモリ 56,312 KB
最終ジャッジ日時 2023-09-04 12:27:43
合計ジャッジ時間 9,292 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,656 KB
testcase_01 AC 127 ms
55,860 KB
testcase_02 AC 127 ms
55,788 KB
testcase_03 AC 126 ms
55,936 KB
testcase_04 AC 126 ms
55,980 KB
testcase_05 AC 128 ms
56,056 KB
testcase_06 AC 127 ms
56,004 KB
testcase_07 AC 127 ms
55,668 KB
testcase_08 AC 125 ms
55,612 KB
testcase_09 AC 126 ms
55,972 KB
testcase_10 AC 128 ms
55,364 KB
testcase_11 AC 125 ms
55,720 KB
testcase_12 AC 128 ms
55,900 KB
testcase_13 AC 127 ms
55,908 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 126 ms
55,708 KB
testcase_17 WA -
testcase_18 AC 126 ms
55,620 KB
testcase_19 AC 128 ms
55,872 KB
testcase_20 WA -
testcase_21 AC 128 ms
55,356 KB
testcase_22 AC 127 ms
55,796 KB
testcase_23 AC 128 ms
55,988 KB
testcase_24 AC 127 ms
55,948 KB
testcase_25 AC 126 ms
56,312 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
55,932 KB
testcase_29 AC 126 ms
56,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No_126 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int s = sc.nextInt();
		int move = 0;
		sc.close();

		int dis_a = 0;
		int dis_b = 0;
		if(a==0){ move+=1;a+=1;}
		
		if (a > s) {
			dis_a = a - s;
		} else {
			dis_a = s - a;
		}
		if (b > s) {
			dis_b = b - s;
		} else {
			dis_b = s - b;
		}
		if(s == 1){
			move+=a;
		}else{
		if (dis_b >= dis_a) {
			move+=dis_a + s;
		}else{
			move+=dis_b;
			if(a > s){
				move+=dis_a + a;
			}else{
				move+=s;
			}
		}
		}
		System.out.println(move);
	}

}
0