結果

問題 No.126 2基のエレベータ
ユーザー YamaKasa
提出日時 2018-07-14 15:48:53
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 2,403 ms
コンパイル使用メモリ 74,044 KB
実行使用メモリ 54,276 KB
最終ジャッジ日時 2024-10-10 05:06:20
合計ジャッジ時間 8,000 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int S = scan.nextInt();
		scan.close();
		int l1 = Math.abs(S - A);
		int l2 = Math.abs(S - B);
		if(l1 <= l2) {
			int ans = l1 + S;
			System.out.println(ans);
		}else {
			int ans = l2;
			if(A == 0) {
				ans += 2 + S - 1;
				System.out.println(ans);
				System.exit(0);
			}
			int t1 = l1 + A;
			int t2 = S - 1 + Math.abs(A - 1);
			ans += Math.min(t1, t2);
			System.out.println(ans);
		}
	}
}
0