結果

問題 No.131 マンハッタン距離
ユーザー YamaKasaYamaKasa
提出日時 2018-07-14 16:49:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 2,245 ms
コンパイル使用メモリ 73,936 KB
実行使用メモリ 41,648 KB
最終ジャッジ日時 2024-04-19 02:23:49
合計ジャッジ時間 6,430 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,244 KB
testcase_01 AC 130 ms
41,172 KB
testcase_02 AC 122 ms
41,504 KB
testcase_03 AC 130 ms
41,504 KB
testcase_04 AC 131 ms
40,832 KB
testcase_05 AC 122 ms
40,352 KB
testcase_06 AC 138 ms
41,248 KB
testcase_07 AC 131 ms
40,908 KB
testcase_08 AC 130 ms
41,148 KB
testcase_09 AC 130 ms
41,144 KB
testcase_10 AC 124 ms
41,184 KB
testcase_11 AC 129 ms
41,028 KB
testcase_12 AC 113 ms
39,740 KB
testcase_13 AC 128 ms
40,656 KB
testcase_14 AC 130 ms
41,424 KB
testcase_15 AC 119 ms
40,572 KB
testcase_16 AC 118 ms
40,840 KB
testcase_17 AC 128 ms
41,380 KB
testcase_18 AC 123 ms
41,032 KB
testcase_19 AC 137 ms
41,188 KB
testcase_20 AC 131 ms
41,304 KB
testcase_21 AC 130 ms
40,984 KB
testcase_22 AC 134 ms
41,648 KB
testcase_23 AC 129 ms
41,424 KB
testcase_24 AC 124 ms
40,776 KB
testcase_25 AC 127 ms
41,488 KB
testcase_26 AC 133 ms
41,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int d = scan.nextInt();
		scan.close();
		if(x + y < d) {
			System.out.println(0);
			System.exit(0);
		}
		if(x >= d && y >= d) {
			System.out.println(d + 1);
		}else if(x < d && y >= d) {
			int ans = d + 1 - (d - x);
			System.out.println(ans);
		}else if(x >= d && y < d) {
			int ans = d + 1 - (d - y);
			System.out.println(ans);
		}else {
			int ans = d + 1 - (d - x) - (d - y);
			System.out.println(ans);
		}

	}
}
0