結果

問題 No.131 マンハッタン距離
ユーザー htensaihtensai
提出日時 2019-12-17 17:23:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 607 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 72,280 KB
実行使用メモリ 49,668 KB
最終ジャッジ日時 2023-09-17 04:15:53
合計ジャッジ時間 4,320 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,416 KB
testcase_01 AC 40 ms
49,340 KB
testcase_02 AC 40 ms
49,292 KB
testcase_03 AC 40 ms
47,300 KB
testcase_04 AC 41 ms
49,412 KB
testcase_05 AC 40 ms
49,388 KB
testcase_06 AC 39 ms
49,448 KB
testcase_07 AC 42 ms
49,400 KB
testcase_08 AC 42 ms
49,396 KB
testcase_09 AC 41 ms
49,320 KB
testcase_10 AC 40 ms
49,204 KB
testcase_11 AC 41 ms
49,392 KB
testcase_12 AC 40 ms
49,320 KB
testcase_13 AC 38 ms
49,396 KB
testcase_14 AC 41 ms
49,252 KB
testcase_15 AC 40 ms
49,244 KB
testcase_16 AC 40 ms
49,252 KB
testcase_17 AC 41 ms
49,444 KB
testcase_18 AC 39 ms
49,420 KB
testcase_19 AC 41 ms
49,480 KB
testcase_20 AC 41 ms
49,256 KB
testcase_21 AC 41 ms
49,232 KB
testcase_22 AC 41 ms
49,668 KB
testcase_23 AC 40 ms
49,400 KB
testcase_24 AC 39 ms
49,240 KB
testcase_25 AC 39 ms
49,252 KB
testcase_26 AC 41 ms
49,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 3);
        int x = Integer.parseInt(first[0]);
        int y = Integer.parseInt(first[1]);
        int d = Integer.parseInt(first[2]);
        if (x + y < d) {
            System.out.println(0);
            return;
        }
        int x1 = Math.min(d, x);
        int x2 = Math.max(0, d - y);
        System.out.println(Math.abs(x1 - x2) + 1);
    }
}
0