結果

問題 No.131 マンハッタン距離
ユーザー tsunatama5tsunatama5
提出日時 2015-02-05 00:05:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,635 ms / 5,000 ms
コード長 720 bytes
コンパイル時間 3,813 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 56,284 KB
最終ジャッジ日時 2023-09-05 11:58:42
合計ジャッジ時間 9,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,112 KB
testcase_01 AC 117 ms
55,744 KB
testcase_02 AC 118 ms
55,928 KB
testcase_03 AC 119 ms
56,104 KB
testcase_04 AC 120 ms
55,896 KB
testcase_05 AC 122 ms
55,720 KB
testcase_06 AC 118 ms
55,708 KB
testcase_07 AC 117 ms
55,712 KB
testcase_08 AC 118 ms
55,712 KB
testcase_09 AC 119 ms
56,132 KB
testcase_10 AC 121 ms
56,096 KB
testcase_11 AC 119 ms
56,220 KB
testcase_12 AC 120 ms
56,284 KB
testcase_13 AC 118 ms
55,544 KB
testcase_14 AC 119 ms
55,672 KB
testcase_15 AC 118 ms
55,632 KB
testcase_16 AC 119 ms
55,908 KB
testcase_17 AC 118 ms
55,732 KB
testcase_18 AC 118 ms
55,668 KB
testcase_19 AC 119 ms
56,052 KB
testcase_20 AC 118 ms
55,920 KB
testcase_21 AC 118 ms
55,812 KB
testcase_22 AC 118 ms
55,856 KB
testcase_23 AC 1,635 ms
55,728 KB
testcase_24 AC 275 ms
55,752 KB
testcase_25 AC 123 ms
55,884 KB
testcase_26 AC 121 ms
55,516 KB
権限があれば一括ダウンロードができます

ソースコード

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