結果

問題 No.131 マンハッタン距離
ユーザー ぴろずぴろず
提出日時 2015-01-20 23:32:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 3,084 ms
コンパイル使用メモリ 71,556 KB
実行使用メモリ 56,336 KB
最終ジャッジ日時 2023-09-05 02:23:21
合計ジャッジ時間 7,792 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,832 KB
testcase_01 AC 125 ms
55,440 KB
testcase_02 AC 124 ms
55,996 KB
testcase_03 AC 123 ms
55,704 KB
testcase_04 AC 125 ms
55,844 KB
testcase_05 AC 126 ms
56,204 KB
testcase_06 AC 125 ms
56,084 KB
testcase_07 AC 122 ms
55,684 KB
testcase_08 AC 123 ms
55,964 KB
testcase_09 AC 122 ms
55,468 KB
testcase_10 AC 123 ms
56,024 KB
testcase_11 AC 122 ms
55,400 KB
testcase_12 AC 124 ms
55,572 KB
testcase_13 AC 122 ms
55,972 KB
testcase_14 AC 125 ms
55,760 KB
testcase_15 AC 126 ms
55,656 KB
testcase_16 AC 125 ms
55,752 KB
testcase_17 AC 121 ms
55,832 KB
testcase_18 AC 124 ms
56,336 KB
testcase_19 AC 124 ms
56,028 KB
testcase_20 AC 121 ms
55,536 KB
testcase_21 AC 124 ms
55,912 KB
testcase_22 AC 123 ms
55,748 KB
testcase_23 AC 124 ms
55,692 KB
testcase_24 AC 127 ms
56,296 KB
testcase_25 AC 127 ms
56,212 KB
testcase_26 AC 124 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no131;

import java.util.Scanner;

public class Main {

	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(solve(x,y,d));
	}

	public static long solve(long x,long y,long d) {
		if (d > x + y) {
			return 0;
		}
		long right = d <= x ? d : x;
		long left = d <= y ? 0 : d - y;
		return right - left + 1;
	}

}
0