結果

問題 No.126 2基のエレベータ
ユーザー kanra661kanra661
提出日時 2015-01-13 23:53:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 5,027 ms
コンパイル使用メモリ 72,056 KB
実行使用メモリ 56,036 KB
最終ジャッジ日時 2023-09-04 06:17:04
合計ジャッジ時間 8,491 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 129 ms
55,452 KB
testcase_02 WA -
testcase_03 AC 128 ms
55,460 KB
testcase_04 AC 129 ms
53,520 KB
testcase_05 AC 128 ms
55,968 KB
testcase_06 WA -
testcase_07 AC 127 ms
55,752 KB
testcase_08 AC 127 ms
55,768 KB
testcase_09 AC 125 ms
55,508 KB
testcase_10 AC 129 ms
55,672 KB
testcase_11 AC 128 ms
55,620 KB
testcase_12 AC 127 ms
55,628 KB
testcase_13 AC 127 ms
55,920 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 127 ms
56,036 KB
testcase_19 AC 126 ms
55,596 KB
testcase_20 WA -
testcase_21 AC 127 ms
55,572 KB
testcase_22 AC 128 ms
55,652 KB
testcase_23 AC 127 ms
55,784 KB
testcase_24 AC 128 ms
55,684 KB
testcase_25 AC 129 ms
55,616 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 127 ms
55,816 KB
testcase_29 AC 129 ms
55,772 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 - s > 0) {
			dis_a = a - s;
		} else {
			dis_a = s - a;
		}
		if (b - s > 0) {
			dis_b = b - s;
		} else {
			dis_b = s - b;
		}
		if(a==0) move+=1;
		if (dis_b >= dis_a) {
			move+=dis_a + s;
		}else{
			move+=dis_b;
			if(a > s){
				move+=dis_a + s;
			}else{
				move+=s;
			}
		}
		System.out.println(move);
	}

}
0