結果

問題 No.131 マンハッタン距離
ユーザー tsunatama5tsunatama5
提出日時 2015-02-07 23:46:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 3,241 ms
コンパイル使用メモリ 72,272 KB
実行使用メモリ 56,088 KB
最終ジャッジ日時 2023-09-05 15:19:03
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,088 KB
testcase_01 AC 120 ms
55,924 KB
testcase_02 AC 121 ms
55,904 KB
testcase_03 AC 120 ms
55,792 KB
testcase_04 AC 120 ms
55,672 KB
testcase_05 AC 122 ms
55,776 KB
testcase_06 AC 126 ms
55,884 KB
testcase_07 AC 122 ms
55,724 KB
testcase_08 AC 122 ms
55,876 KB
testcase_09 AC 120 ms
55,456 KB
testcase_10 AC 120 ms
55,984 KB
testcase_11 AC 116 ms
55,292 KB
testcase_12 AC 122 ms
55,712 KB
testcase_13 AC 119 ms
55,880 KB
testcase_14 AC 118 ms
55,780 KB
testcase_15 AC 120 ms
56,084 KB
testcase_16 AC 119 ms
55,856 KB
testcase_17 AC 119 ms
55,468 KB
testcase_18 AC 116 ms
56,068 KB
testcase_19 AC 121 ms
55,456 KB
testcase_20 AC 120 ms
55,652 KB
testcase_21 AC 120 ms
55,588 KB
testcase_22 AC 119 ms
55,640 KB
testcase_23 AC 121 ms
55,760 KB
testcase_24 AC 121 ms
55,476 KB
testcase_25 AC 119 ms
55,644 KB
testcase_26 AC 121 ms
55,760 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 x = nint[0];
		int y = nint[1];
		int d = nint[2];
		int ans = 0;
		int flags = 0;
		
		if (d>x+y) {
			flags ++;
		} 
		
		int xmax = 0;
		int xmin = 0;
		
		if (d<=x) {
			xmax = d;
		} else if (d>x) {
			xmax = x;
		}
		
		if (d>y) {
			xmin = d-y;
		} else if (d<=y) {
			xmin = 0;
		}
		
		if (flags == 0) {
			ans = xmax - (xmin - 1);
		}
		
		System.out.println(ans);		
	}
}
0