結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 123 ms
56,088 KB
testcase_02 WA -
testcase_03 AC 123 ms
55,536 KB
testcase_04 AC 122 ms
55,672 KB
testcase_05 AC 120 ms
55,812 KB
testcase_06 AC 121 ms
56,192 KB
testcase_07 AC 121 ms
55,648 KB
testcase_08 AC 120 ms
55,836 KB
testcase_09 AC 120 ms
55,596 KB
testcase_10 AC 121 ms
55,540 KB
testcase_11 AC 120 ms
55,564 KB
testcase_12 WA -
testcase_13 AC 123 ms
57,596 KB
testcase_14 AC 123 ms
55,676 KB
testcase_15 AC 121 ms
55,680 KB
testcase_16 WA -
testcase_17 AC 122 ms
55,532 KB
testcase_18 AC 123 ms
56,060 KB
testcase_19 AC 125 ms
55,608 KB
testcase_20 AC 123 ms
55,356 KB
testcase_21 AC 122 ms
55,552 KB
testcase_22 AC 123 ms
55,908 KB
testcase_23 AC 122 ms
55,928 KB
testcase_24 AC 123 ms
55,600 KB
testcase_25 AC 121 ms
55,616 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  Math.min(lb + Math.abs(a-b) + a,lb + (s-1) + a);
			}
		}
	}

}
0