結果

問題 No.126 2基のエレベータ
ユーザー uafr_csuafr_cs
提出日時 2015-09-02 17:59:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 72,792 KB
実行使用メモリ 56,508 KB
最終ジャッジ日時 2023-09-26 02:13:47
合計ジャッジ時間 7,446 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 125 ms
55,948 KB
testcase_03 AC 123 ms
56,164 KB
testcase_04 AC 123 ms
55,836 KB
testcase_05 AC 124 ms
55,736 KB
testcase_06 AC 125 ms
55,796 KB
testcase_07 WA -
testcase_08 AC 125 ms
55,836 KB
testcase_09 AC 122 ms
55,976 KB
testcase_10 AC 126 ms
55,592 KB
testcase_11 AC 122 ms
55,684 KB
testcase_12 WA -
testcase_13 AC 125 ms
55,628 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 123 ms
55,544 KB
testcase_19 AC 124 ms
56,156 KB
testcase_20 WA -
testcase_21 AC 125 ms
56,016 KB
testcase_22 AC 125 ms
55,824 KB
testcase_23 AC 125 ms
55,728 KB
testcase_24 AC 127 ms
55,740 KB
testcase_25 AC 127 ms
55,556 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int A = sc.nextInt();
		final int B = sc.nextInt();
		final int S = sc.nextInt();
		
		if(S == 1){ // always A
			System.out.println(Math.abs(1 - A) + 1);
		}else{
			final int SA_dist = Math.abs(A - S);
			final int SB_dist = Math.abs(B - S);
			
			if(SA_dist <= SB_dist){ // near A
				System.out.println(SA_dist + S);
			}else{ // near B
				System.out.println(SB_dist + (A - 1) + B);
			}
			
		}
		
	}
	
}
0