結果

問題 No.131 マンハッタン距離
ユーザー GrenacheGrenache
提出日時 2015-12-29 00:22:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 4,615 ms
コンパイル使用メモリ 74,204 KB
実行使用メモリ 57,576 KB
最終ジャッジ日時 2023-10-19 12:11:30
合計ジャッジ時間 9,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,272 KB
testcase_01 AC 134 ms
57,120 KB
testcase_02 AC 135 ms
57,128 KB
testcase_03 AC 136 ms
57,528 KB
testcase_04 AC 134 ms
57,308 KB
testcase_05 AC 132 ms
57,412 KB
testcase_06 AC 132 ms
57,296 KB
testcase_07 AC 130 ms
57,224 KB
testcase_08 AC 134 ms
57,244 KB
testcase_09 AC 135 ms
57,316 KB
testcase_10 AC 136 ms
57,408 KB
testcase_11 AC 140 ms
57,108 KB
testcase_12 AC 139 ms
57,356 KB
testcase_13 AC 133 ms
57,280 KB
testcase_14 AC 135 ms
57,576 KB
testcase_15 AC 134 ms
57,352 KB
testcase_16 AC 134 ms
57,440 KB
testcase_17 AC 136 ms
57,444 KB
testcase_18 AC 146 ms
57,480 KB
testcase_19 AC 138 ms
57,352 KB
testcase_20 AC 134 ms
57,424 KB
testcase_21 AC 138 ms
57,144 KB
testcase_22 AC 137 ms
57,388 KB
testcase_23 AC 136 ms
57,344 KB
testcase_24 AC 135 ms
57,332 KB
testcase_25 AC 136 ms
57,416 KB
testcase_26 AC 138 ms
57,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder131 {

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

        int x = sc.nextInt();
        int y = sc.nextInt();
        int d = sc.nextInt();

        System.out.println(getArea(0, 0, x, y, d));

        sc.close();
    }

    private static long getArea(long x1, long y1, long x2, long y2, long d) {
    	if (x2 + y2 == d) {
    		return 1;
    	} else if (x2 + y2 < d) {
    		return 0;
    	} if (x2 >= d && y2 >= d) {
    		return d + 1;
    	} if (x2 >= d) {
    		return y2 + 1;
    	} if (y2 >= d) {
    		return x2 + 1;
    	} else {
    		return d + 1 - (d - x2) - (d - y2);
    	}
	}
}
0