結果

問題 No.131 マンハッタン距離
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-21 21:49:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 71,668 KB
実行使用メモリ 56,372 KB
最終ジャッジ日時 2023-08-18 06:14:17
合計ジャッジ時間 6,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,744 KB
testcase_01 AC 118 ms
55,788 KB
testcase_02 AC 117 ms
56,128 KB
testcase_03 AC 121 ms
56,152 KB
testcase_04 AC 119 ms
56,056 KB
testcase_05 AC 119 ms
56,100 KB
testcase_06 AC 121 ms
55,896 KB
testcase_07 AC 124 ms
55,812 KB
testcase_08 AC 119 ms
56,020 KB
testcase_09 AC 119 ms
56,108 KB
testcase_10 AC 117 ms
56,084 KB
testcase_11 AC 116 ms
56,164 KB
testcase_12 AC 121 ms
56,124 KB
testcase_13 AC 118 ms
56,184 KB
testcase_14 AC 120 ms
56,124 KB
testcase_15 AC 118 ms
55,992 KB
testcase_16 AC 119 ms
55,776 KB
testcase_17 AC 119 ms
56,016 KB
testcase_18 AC 122 ms
56,172 KB
testcase_19 AC 119 ms
56,372 KB
testcase_20 AC 119 ms
55,980 KB
testcase_21 AC 116 ms
55,960 KB
testcase_22 AC 118 ms
55,716 KB
testcase_23 AC 120 ms
55,740 KB
testcase_24 AC 117 ms
55,832 KB
testcase_25 AC 119 ms
56,040 KB
testcase_26 AC 119 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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();
        int dx=0;
        int dy=0;
        if(d>x){dx=d-x;}
        if(d>y){dy=d-y;}
        int ans=d+1-dx-dy;
        if(ans<0){ans=0;}
        System.out.println(ans);
    }
}
0