結果

問題 No.126 2基のエレベータ
ユーザー uafr_csuafr_cs
提出日時 2015-09-02 18:21:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 72,048 KB
実行使用メモリ 57,532 KB
最終ジャッジ日時 2023-09-26 02:14:18
合計ジャッジ時間 7,005 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,428 KB
testcase_01 WA -
testcase_02 AC 120 ms
55,692 KB
testcase_03 AC 119 ms
56,120 KB
testcase_04 AC 121 ms
56,004 KB
testcase_05 AC 121 ms
55,828 KB
testcase_06 AC 122 ms
55,632 KB
testcase_07 WA -
testcase_08 AC 123 ms
55,448 KB
testcase_09 AC 122 ms
56,352 KB
testcase_10 AC 122 ms
56,164 KB
testcase_11 AC 122 ms
56,444 KB
testcase_12 AC 120 ms
55,652 KB
testcase_13 AC 123 ms
55,692 KB
testcase_14 AC 124 ms
55,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 126 ms
55,704 KB
testcase_19 AC 125 ms
55,444 KB
testcase_20 WA -
testcase_21 AC 121 ms
55,500 KB
testcase_22 AC 123 ms
55,904 KB
testcase_23 AC 122 ms
56,216 KB
testcase_24 AC 122 ms
55,996 KB
testcase_25 AC 122 ms
55,872 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 + Math.min(SA_dist + A, B + A));
			}
			
		}
		
	}
	
}
0