結果

問題 No.131 マンハッタン距離
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-19 22:12:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 569 bytes
コンパイル時間 2,788 ms
コンパイル使用メモリ 74,676 KB
実行使用メモリ 41,648 KB
最終ジャッジ日時 2024-04-19 13:02:23
合計ジャッジ時間 6,654 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
41,556 KB
testcase_01 AC 110 ms
41,104 KB
testcase_02 AC 120 ms
41,012 KB
testcase_03 AC 129 ms
41,336 KB
testcase_04 AC 126 ms
40,876 KB
testcase_05 AC 126 ms
41,000 KB
testcase_06 AC 114 ms
41,436 KB
testcase_07 AC 96 ms
41,116 KB
testcase_08 AC 114 ms
41,556 KB
testcase_09 AC 119 ms
41,240 KB
testcase_10 AC 110 ms
40,932 KB
testcase_11 AC 103 ms
41,648 KB
testcase_12 AC 102 ms
41,052 KB
testcase_13 AC 99 ms
41,108 KB
testcase_14 AC 107 ms
41,256 KB
testcase_15 AC 106 ms
40,748 KB
testcase_16 AC 115 ms
41,380 KB
testcase_17 AC 113 ms
41,040 KB
testcase_18 AC 109 ms
41,072 KB
testcase_19 AC 112 ms
41,188 KB
testcase_20 AC 101 ms
41,160 KB
testcase_21 AC 107 ms
41,452 KB
testcase_22 AC 102 ms
41,196 KB
testcase_23 AC 113 ms
41,304 KB
testcase_24 AC 98 ms
41,512 KB
testcase_25 AC 110 ms
41,500 KB
testcase_26 AC 100 ms
41,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise98{
  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 smaller = Math.min(x, y);
    int bigger = Math.max(x, y);

    if(d < smaller){
      System.out.println(d - 1 + 2);
    }else if(d >= smaller && d <= bigger){
      System.out.println(smaller - 1 + 2);
    }else if(d <= bigger + smaller){
      System.out.println((bigger + smaller - d) - 1 + 2);
    }else{
      System.out.println(0);
    }
  }
}
0