結果

問題 No.131 マンハッタン距離
ユーザー koheiarai94koheiarai94
提出日時 2017-09-25 02:08:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 578 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 41,696 KB
最終ジャッジ日時 2024-04-26 17:56:15
合計ジャッジ時間 7,200 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
40,176 KB
testcase_01 AC 132 ms
41,380 KB
testcase_02 AC 135 ms
41,584 KB
testcase_03 AC 132 ms
41,452 KB
testcase_04 AC 135 ms
41,148 KB
testcase_05 AC 134 ms
41,388 KB
testcase_06 AC 138 ms
41,536 KB
testcase_07 AC 141 ms
41,188 KB
testcase_08 AC 139 ms
41,316 KB
testcase_09 AC 140 ms
41,268 KB
testcase_10 AC 141 ms
41,472 KB
testcase_11 AC 137 ms
41,388 KB
testcase_12 AC 144 ms
41,620 KB
testcase_13 AC 142 ms
41,276 KB
testcase_14 AC 142 ms
41,504 KB
testcase_15 AC 142 ms
41,252 KB
testcase_16 AC 137 ms
41,176 KB
testcase_17 AC 142 ms
41,568 KB
testcase_18 AC 138 ms
41,504 KB
testcase_19 AC 144 ms
41,572 KB
testcase_20 AC 142 ms
41,572 KB
testcase_21 AC 139 ms
41,324 KB
testcase_22 AC 144 ms
41,260 KB
testcase_23 AC 143 ms
41,576 KB
testcase_24 AC 143 ms
41,516 KB
testcase_25 AC 139 ms
41,512 KB
testcase_26 AC 139 ms
41,696 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