結果

問題 No.126 2基のエレベータ
コンテスト
ユーザー 3pstn
提出日時 2015-01-25 15:47:38
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 562 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,809 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 47,112 KB
最終ジャッジ日時 2026-03-07 16:28:59
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;
public class Main {
	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 sum = 0;

		if(Math.abs(a-s) < Math.abs(b-s)){
			// aの方が近い
			sum += Math.abs(a-s) + s;
		}else{
			// bの方が近い
			if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))){
				a++;
				sum++;
			}
			sum += Math.abs(b-s) + Math.abs(s-a) + a;
			// if(a == 0 && (Math.abs(a-s) != Math.abs(b-s))) {
			// 	sum++;
			// }
		}
		System.out.println(sum);
	}
}
0