結果

問題 No.131 マンハッタン距離
ユーザー Grenache
提出日時 2015-12-29 00:22:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 5,439 ms
コンパイル使用メモリ 74,140 KB
実行使用メモリ 41,788 KB
最終ジャッジ日時 2024-09-19 08:15:16
合計ジャッジ時間 8,825 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

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