結果

問題 No.131 マンハッタン距離
ユーザー k_kadorak_kadora
提出日時 2015-05-26 03:24:39
言語 Java19
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 412 bytes
コンパイル時間 3,612 ms
コンパイル使用メモリ 71,752 KB
実行使用メモリ 56,160 KB
最終ジャッジ日時 2023-09-20 13:20:16
合計ジャッジ時間 8,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,756 KB
testcase_01 AC 126 ms
55,676 KB
testcase_02 AC 127 ms
55,852 KB
testcase_03 AC 125 ms
55,864 KB
testcase_04 AC 127 ms
55,784 KB
testcase_05 AC 129 ms
55,740 KB
testcase_06 AC 130 ms
55,408 KB
testcase_07 AC 126 ms
55,468 KB
testcase_08 AC 126 ms
56,032 KB
testcase_09 AC 124 ms
55,628 KB
testcase_10 AC 124 ms
56,008 KB
testcase_11 AC 126 ms
55,852 KB
testcase_12 AC 126 ms
55,660 KB
testcase_13 AC 125 ms
55,676 KB
testcase_14 AC 126 ms
55,892 KB
testcase_15 AC 126 ms
55,848 KB
testcase_16 AC 130 ms
55,428 KB
testcase_17 AC 127 ms
55,804 KB
testcase_18 AC 127 ms
56,008 KB
testcase_19 AC 124 ms
55,628 KB
testcase_20 AC 125 ms
56,160 KB
testcase_21 AC 126 ms
55,788 KB
testcase_22 AC 126 ms
55,876 KB
testcase_23 AC 126 ms
55,412 KB
testcase_24 AC 125 ms
55,624 KB
testcase_25 AC 125 ms
55,712 KB
testcase_26 AC 124 ms
55,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Distance {
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int x,y,d,res,temp;
		x = sc.nextInt();
		y = sc.nextInt();
		d = sc.nextInt();
		if(d<x){
			if(d<y){
				res = d+1;
			}else{
				res = y + 1;
			}
		}else{
			if(d<y){
				res = x + 1;
			}else{
				res = x + y + 1 - d;
				if(res < 0)res = 0;
			}
		}
		System.out.println(res);
	}
}
0