結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,312 KB
testcase_01 AC 44 ms
49,364 KB
testcase_02 AC 43 ms
49,340 KB
testcase_03 AC 44 ms
49,564 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 45 ms
49,800 KB
testcase_08 AC 46 ms
49,228 KB
testcase_09 AC 45 ms
47,212 KB
testcase_10 WA -
testcase_11 AC 47 ms
49,296 KB
testcase_12 AC 45 ms
49,296 KB
testcase_13 AC 45 ms
49,364 KB
testcase_14 WA -
testcase_15 AC 44 ms
49,156 KB
testcase_16 AC 45 ms
49,184 KB
testcase_17 AC 45 ms
49,328 KB
testcase_18 WA -
testcase_19 AC 44 ms
49,304 KB
testcase_20 AC 46 ms
49,368 KB
testcase_21 WA -
testcase_22 AC 46 ms
49,652 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());
            long x = a[0];
            long y = a[1];
            a = strToIntArray(br.readLine());
            long x2 = a[0];
            long y2 = a[1];
            long min = Math.min(x, y);
            long 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 + 3);
            } else {
                System.out.println(min + sub);
            }
        } 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