結果

問題 No.126 2基のエレベータ
ユーザー aaaaasatori
提出日時 2018-02-19 17:54:29
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 3,335 ms
コンパイル使用メモリ 74,132 KB
実行使用メモリ 54,840 KB
最終ジャッジ日時 2024-07-08 09:18:15
合計ジャッジ時間 7,610 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No126 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int S = sc.nextInt();
		int l = 0; //距離
		if(S == 0) {
			System.out.println(0);
			return;
		}
		if(S == 1) {
			System.out.println(Math.abs(A-S) + S);
			return;
		}
		
		if(Math.abs(A-S) <= Math.abs(B-S)) {
			System.out.println(Math.abs(A-S) + S);
		}else if(Math.abs(S-1) <= Math.abs(S-A)) {
			System.out.println(Math.abs(S-B)+S-1+A);
		}
		else {
				System.out.println(Math.abs(A-B)+A);
		}
		
	}
}
0