結果

問題 No.131 マンハッタン距離
ユーザー koheiarai94koheiarai94
提出日時 2017-09-25 02:08:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 578 bytes
コンパイル時間 1,829 ms
コンパイル使用メモリ 71,896 KB
実行使用メモリ 57,624 KB
最終ジャッジ日時 2023-08-09 02:24:13
合計ジャッジ時間 6,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,984 KB
testcase_01 AC 115 ms
55,936 KB
testcase_02 AC 118 ms
56,264 KB
testcase_03 AC 118 ms
56,076 KB
testcase_04 AC 116 ms
56,136 KB
testcase_05 AC 115 ms
55,768 KB
testcase_06 AC 117 ms
56,196 KB
testcase_07 AC 113 ms
55,996 KB
testcase_08 AC 118 ms
56,272 KB
testcase_09 AC 118 ms
55,628 KB
testcase_10 AC 117 ms
56,072 KB
testcase_11 AC 118 ms
57,624 KB
testcase_12 AC 122 ms
56,472 KB
testcase_13 AC 117 ms
56,448 KB
testcase_14 AC 115 ms
55,684 KB
testcase_15 AC 118 ms
56,028 KB
testcase_16 AC 117 ms
55,948 KB
testcase_17 AC 117 ms
55,836 KB
testcase_18 AC 117 ms
56,460 KB
testcase_19 AC 117 ms
55,684 KB
testcase_20 AC 118 ms
56,080 KB
testcase_21 AC 117 ms
55,656 KB
testcase_22 AC 118 ms
56,016 KB
testcase_23 AC 119 ms
55,436 KB
testcase_24 AC 121 ms
55,648 KB
testcase_25 AC 116 ms
56,344 KB
testcase_26 AC 115 ms
54,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

// Yuki 131
// https://yukicoder.me/problems/no/131

public class Main {
	
	public static void main (String[] args) throws InterruptedException {
		Scanner in = new Scanner(System.in);
		
		int x = in.nextInt();
		int y = in.nextInt();
		int d = in.nextInt();
		
		int answer = 0;
		if (d <= y) {
			answer = Math.min(d,  x) + 1;
		} else if (d <= x) {
			answer = Math.min(d, y) + 1;
		} else {
			int crossX = d - y;
			if (0 <= crossX && crossX <= x) {
				int crossY = 0 - x + d;
				answer = y - crossY + 1;
			}
		}
		System.out.println(answer);
	}
}
0