結果

問題 No.208 王将
ユーザー mobius_bkstmobius_bkst
提出日時 2015-05-15 22:48:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,190 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 74,880 KB
実行使用メモリ 51,468 KB
最終ジャッジ日時 2023-09-20 08:26:39
合計ジャッジ時間 5,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
49,392 KB
testcase_02 AC 42 ms
49,196 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 40 ms
49,440 KB
testcase_08 AC 41 ms
49,360 KB
testcase_09 AC 41 ms
49,240 KB
testcase_10 WA -
testcase_11 AC 43 ms
49,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 42 ms
49,224 KB
testcase_20 AC 44 ms
49,244 KB
testcase_21 WA -
testcase_22 AC 44 ms
49,412 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class No208 {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            int[] a = strToIntArray(br.readLine());
            int x = a[0];
            int y = a[1];
            a = strToIntArray(br.readLine());
            int x2 = a[0];
            int y2 = a[1];
            int min = Math.min(x, y);
            int sub = Math.abs(x - y);

            boolean isSameSide = x * x2 > 0 && y * y2 > 0;

            if (Math.abs(x2) - Math.abs(y2) != 0 && !isSameSide) {
                System.out.println(min + sub);
            } else {
                System.out.println(min + sub + 3);
            }
        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

    static int[] strToIntArray(String S) {
        String[] strArray = S.split(" ");
        int[] intArray = new int[strArray.length];
        for (int i = 0; i < strArray.length; i++) {
            intArray[i] = Integer.parseInt(strArray[i]);
        }
        return intArray;
    }
}
0