結果

問題 No.131 マンハッタン距離
ユーザー tsunatama5
提出日時 2015-02-05 00:05:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 964 ms / 5,000 ms
コード長 720 bytes
コンパイル時間 3,174 ms
コンパイル使用メモリ 77,488 KB
実行使用メモリ 41,448 KB
最終ジャッジ日時 2024-06-23 07:35:44
合計ジャッジ時間 7,653 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class P131 {
	public static void main(String args[]) {
		
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		String[] nstrs = n.split(" ");
		int nint[] = new int[3];
		
		for (int a=0;a<3;a++) {
			nint[a] = Integer.parseInt(nstrs[a]);
		}
		
		int x1 = nint[0];
		int y1 = nint[1];
		int d = nint[2];
		int x;
		int ans = 0;
		int lim;
		int xst;
		
		if ((d-y1) < 0) {
			lim = 0;
		} else {
			lim = d-y1;
		}
		
		if (x1 < d) {
			xst = x1;
		} else {
			xst = d;
		}
		
		if (d > (x1+y1)) {
		} else if (d==(x1+y1)) {
			ans = 1;
		} else {
			for (x=xst;x>=lim;x--) {
				if ((d-x)>=0 && y1>=(d-x)) {
					ans++;
				}
			}
		}
		System.out.println(ans);		
	}
}
0