結果

問題 No.126 2基のエレベータ
ユーザー crazybbb3crazybbb3
提出日時 2017-01-30 22:48:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 1,921 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 79,112 KB
実行使用メモリ 37,400 KB
最終ジャッジ日時 2024-04-19 01:51:14
合計ジャッジ時間 4,789 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,344 KB
testcase_01 AC 54 ms
37,400 KB
testcase_02 AC 54 ms
37,372 KB
testcase_03 AC 53 ms
37,160 KB
testcase_04 AC 52 ms
37,236 KB
testcase_05 AC 53 ms
37,056 KB
testcase_06 AC 54 ms
37,248 KB
testcase_07 AC 52 ms
37,400 KB
testcase_08 AC 53 ms
37,248 KB
testcase_09 AC 53 ms
37,400 KB
testcase_10 AC 52 ms
37,032 KB
testcase_11 AC 53 ms
37,372 KB
testcase_12 AC 52 ms
37,316 KB
testcase_13 AC 52 ms
37,236 KB
testcase_14 AC 52 ms
37,248 KB
testcase_15 AC 52 ms
36,676 KB
testcase_16 AC 53 ms
37,120 KB
testcase_17 AC 53 ms
37,304 KB
testcase_18 AC 52 ms
37,052 KB
testcase_19 AC 52 ms
37,304 KB
testcase_20 AC 53 ms
37,160 KB
testcase_21 AC 50 ms
36,680 KB
testcase_22 AC 52 ms
37,372 KB
testcase_23 AC 52 ms
37,344 KB
testcase_24 AC 52 ms
37,324 KB
testcase_25 AC 52 ms
37,276 KB
testcase_26 AC 53 ms
37,068 KB
testcase_27 AC 52 ms
37,196 KB
testcase_28 AC 52 ms
37,372 KB
testcase_29 AC 52 ms
37,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    void solve() throws IOException {
        int a = ni(), b = ni(), s = ni();

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

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0