結果

問題 No.126 2基のエレベータ
ユーザー GrenacheGrenache
提出日時 2015-12-21 23:42:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 1,902 bytes
コンパイル時間 3,771 ms
コンパイル使用メモリ 78,956 KB
実行使用メモリ 37,400 KB
最終ジャッジ日時 2024-04-19 01:47:42
合計ジャッジ時間 6,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,332 KB
testcase_01 AC 52 ms
36,808 KB
testcase_02 AC 52 ms
37,004 KB
testcase_03 AC 53 ms
37,160 KB
testcase_04 AC 53 ms
36,944 KB
testcase_05 AC 52 ms
36,780 KB
testcase_06 AC 53 ms
37,152 KB
testcase_07 AC 52 ms
37,344 KB
testcase_08 AC 53 ms
37,360 KB
testcase_09 AC 53 ms
37,304 KB
testcase_10 AC 53 ms
37,372 KB
testcase_11 AC 53 ms
37,248 KB
testcase_12 AC 52 ms
37,264 KB
testcase_13 AC 52 ms
37,372 KB
testcase_14 AC 52 ms
37,372 KB
testcase_15 AC 51 ms
37,104 KB
testcase_16 AC 51 ms
37,344 KB
testcase_17 AC 53 ms
37,144 KB
testcase_18 AC 51 ms
37,044 KB
testcase_19 AC 54 ms
37,044 KB
testcase_20 AC 53 ms
36,924 KB
testcase_21 AC 53 ms
37,312 KB
testcase_22 AC 53 ms
37,244 KB
testcase_23 AC 52 ms
37,236 KB
testcase_24 AC 52 ms
37,032 KB
testcase_25 AC 52 ms
37,400 KB
testcase_26 AC 52 ms
36,768 KB
testcase_27 AC 53 ms
36,808 KB
testcase_28 AC 53 ms
37,156 KB
testcase_29 AC 52 ms
37,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;


public class Main_yukicoder126 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int s = sc.nextInt();

        if (s == 1 || Math.abs(a - s) <= Math.abs(b - s)) {
        	pr.println(Math.abs(a - s) + s);
        } else {
        	if (a > 0) {
        		pr.println(Math.abs(b - s) + (a < s ? s : a + Math.min(Math.abs(a - s), Math.abs(s - 1))));
        	} else {
        		pr.println(Math.abs(b - s) + s - 1 + 2);
        	}
        }

        pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0