結果

問題 No.131 マンハッタン距離
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-06 10:56:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 741 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 71,468 KB
実行使用メモリ 56,400 KB
最終ジャッジ日時 2023-09-17 06:10:38
合計ジャッジ時間 6,424 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,732 KB
testcase_01 AC 124 ms
55,768 KB
testcase_02 AC 123 ms
55,788 KB
testcase_03 AC 123 ms
56,184 KB
testcase_04 AC 122 ms
55,964 KB
testcase_05 AC 121 ms
56,240 KB
testcase_06 AC 121 ms
55,692 KB
testcase_07 AC 125 ms
55,804 KB
testcase_08 AC 124 ms
55,860 KB
testcase_09 AC 124 ms
55,964 KB
testcase_10 AC 125 ms
56,248 KB
testcase_11 AC 126 ms
55,692 KB
testcase_12 AC 125 ms
55,524 KB
testcase_13 AC 124 ms
55,756 KB
testcase_14 AC 125 ms
55,628 KB
testcase_15 AC 125 ms
55,704 KB
testcase_16 AC 124 ms
55,676 KB
testcase_17 AC 125 ms
56,040 KB
testcase_18 AC 124 ms
55,960 KB
testcase_19 AC 123 ms
56,304 KB
testcase_20 AC 116 ms
56,016 KB
testcase_21 AC 124 ms
55,884 KB
testcase_22 AC 125 ms
56,136 KB
testcase_23 AC 123 ms
55,924 KB
testcase_24 AC 124 ms
56,164 KB
testcase_25 AC 122 ms
56,400 KB
testcase_26 AC 123 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
       int x = koko.nextInt();
       int y = koko.nextInt();
       int d = koko.nextInt();
       int point;
       if(d>x+y){
           point = 0;
       }else if(x<y){
           if(d<x){
               point=d+1;
           }else if(x<=d&&d<=y){
               point=x+1;
           }else{
               point = x+y+1-d;
           }
       }else{
           if(d<y){
               point=d+1;
           }else if(y<=d&&d<=x){
               point = y+1;
           }else{
               point = x+y+1-d;
           }
       }
       
       System.out.println(point);
    }
}

0