結果

問題 No.126 2基のエレベータ
ユーザー ぴろずぴろず
提出日時 2015-01-13 23:43:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 4,237 ms
コンパイル使用メモリ 71,096 KB
実行使用メモリ 57,532 KB
最終ジャッジ日時 2023-09-04 06:10:21
合計ジャッジ時間 7,378 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 127 ms
55,740 KB
testcase_02 WA -
testcase_03 AC 128 ms
55,788 KB
testcase_04 AC 126 ms
55,544 KB
testcase_05 AC 126 ms
55,636 KB
testcase_06 AC 128 ms
55,540 KB
testcase_07 AC 125 ms
55,460 KB
testcase_08 AC 127 ms
55,444 KB
testcase_09 AC 129 ms
55,208 KB
testcase_10 AC 130 ms
55,732 KB
testcase_11 AC 128 ms
55,744 KB
testcase_12 WA -
testcase_13 AC 132 ms
55,360 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 127 ms
55,716 KB
testcase_18 AC 127 ms
55,992 KB
testcase_19 AC 127 ms
55,676 KB
testcase_20 WA -
testcase_21 AC 127 ms
55,604 KB
testcase_22 AC 127 ms
55,244 KB
testcase_23 AC 123 ms
55,800 KB
testcase_24 AC 126 ms
55,556 KB
testcase_25 AC 126 ms
55,620 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package no126;

import java.util.Scanner;

public 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();
		System.out.println(solve(a,b,c));
	}

	public static int solve(int a,int b,int s) {
		int la = Math.abs(a-s);
		int lb = Math.abs(b-s);
		int ans = 0;
		if (a == 0) {
			if (la <= lb) {
				return la + s;
			}else{
				return lb + s + 1;
			}
		}else{
			if (la <= lb) {
				return la + s;
			}else{
				return lb + Math.abs(a-b) + a;
			}
		}
	}

}
0